Skip to content

Conversation

@VynDragon
Copy link
Contributor

What's in the title.

Large update that cannot be cut without breaking functionality.

Some drivers are getting entirely revamped, such as uart and pinctrl, do not consider those as updates of the older drivers, but rather new drivers (which is true to some large extent).

@VynDragon VynDragon requested a review from nandojve June 21, 2025 19:54
@VynDragon VynDragon changed the title Make BFLB not used the SDK code Make BFLB not use the SDK code Jun 21, 2025
@VynDragon VynDragon force-pushed the bl60x_nosdk branch 5 times, most recently from 6e0c76d to f2a098f Compare June 21, 2025 20:59
}
/* clear interrupts that require ack*/
tmp = sys_read32(cfg->base_reg + UART_INT_CLEAR_OFFSET);
tmp = tmp | UART_CR_URX_RTO_CLR;
Copy link
Contributor

@kartben kartben Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's more that needs clearing, e.g. you've enabled PCE so UART_CR_URX_PCE_CLR ; probably UART_CR_URX_END_CLR and UART_CR_UTX_END_CLR as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay no, deleted message was right but i looked at the wrong place UART_CR_URX_END_CLR and UART_CR_UTX_END_CLR 's interrupts should be masked and UART_CR_URX_PCE_CLR is handled in uart_bflb_err_check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(masked = interrupt not thrown to CPU, but i think it was required for working?)

Comment on lines 25 to 32
void riscv_clic_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags)
{
ARG_UNUSED(irq);
ARG_UNUSED(prio);
ARG_UNUSED(flags);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to document why it's not being implemented? Or... should it be implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably yes, will look into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shell sample isnt working on this PR while it should anyway so i have some checks to do...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with debugger.... uuuurgh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing this has had the knock-off effect of somehow fixing the shell sample without the little wait I just added... Sometimes I really dont understand those chips...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 196 to 200
tmp = sys_read32(cfg->base_reg + UART_STATUS_OFFSET);
rc = tmp & UART_STS_UTX_BUS_BUSY;
tmp = sys_read32(cfg->base_reg + UART_FIFO_CONFIG_1_OFFSET);
rc += tmp & UART_TX_FIFO_CNT_MASK;
return (rc > 0 ? 1 : 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you have the logic backwards?
irq_tx_complete returns 1 If nothing remains to be transmitted ; 0 If transmission is not completed.

tx is probably not complete if UART_STS_UTX_BUS_BUSY is set or if FIFO still contains data?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like it yes

Copy link
Contributor Author

@VynDragon VynDragon Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Note tx fifo count is inverted, it counts free bytes.

Comment on lines +127 to +144
int uart_bflb_irq_tx_ready(const struct device *dev)
{
const struct bflb_config *const cfg = dev->config;
uint32_t tmp = 0;

tmp = sys_read32(cfg->base_reg + UART_FIFO_CONFIG_1_OFFSET);
return (tmp & UART_TX_FIFO_CNT_MASK) > 0;
}

int uart_bflb_irq_rx_ready(const struct device *dev)
{
const struct bflb_config *const cfg = dev->config;
uint32_t tmp = 0;

tmp = sys_read32(cfg->base_reg + UART_FIFO_CONFIG_1_OFFSET);
return (tmp & UART_RX_FIFO_CNT_MASK) > 0;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you've setup thresholds so raw count shouldn't be used? I think this should instead check if UART_URX_FIFO_INT / UART_UTX_FIFO_INT are set/pending.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These interrupts are masked, functionally it's the same (And there might have been a reason, interrupts gave me, and continue to give me, a lot of trouble on this platform, I wouldnt remember but it's possible there was issues doing it with the interrupt).

reg mstatus 0x7800
reg mie 0x0
# reg pc 0x23000000
reg mstatus 0x80000000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bit 31 of mstatus is read-only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where that's from, I see the same, maybe 0x0 is more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@VynDragon VynDragon force-pushed the bl60x_nosdk branch 3 times, most recently from 418a18c to 382a12e Compare July 7, 2025 11:32
@VynDragon VynDragon requested review from kartben and nandojve July 10, 2025 09:06
@VynDragon
Copy link
Contributor Author

Rebased on main.

@VynDragon VynDragon force-pushed the bl60x_nosdk branch 2 times, most recently from 83cb97c to dd434c7 Compare July 18, 2025 18:14
@VynDragon
Copy link
Contributor Author

Squashed commits that couldn't build by themselves (so almost all of them...)

Copy link
Member

@nandojve nandojve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see more points for improvement but since this is a big change already I think it is fine to move this way. Then we improve gradually to avoid stuck the PR.

This reverts 514258a
which causes issues here

Signed-off-by: Camille BAUD <[email protected]>
@VynDragon
Copy link
Contributor Author

rebased on main

Reorganize and update soc folder files for SDK-independance
Reorganize and update hal_bouffalolab files for SDK-independance
Reorganize and update soc dts files for SDK-independance
Update serial and pinctrl driver files for SDK-independance
Update ai_wb2_12f, bl604e_iot_dvk, and dt_bl10_dvk
to new bl60x support
and fixup openocd config of ai_wb2_12f

Signed-off-by: Camille BAUD <[email protected]>
mostly makes things a little bit safer

Signed-off-by: Camille BAUD <[email protected]>
@sonarqubecloud
Copy link

@nandojve
Copy link
Member

nandojve commented Aug 1, 2025

ping @kartben

@cfriedt cfriedt merged commit 633c0fe into zephyrproject-rtos:main Aug 1, 2025
27 checks passed
@maass-hamburg
Copy link
Member

regarding soc: bflb: re-add ATOMIC_OPERATIONS_C are you sure, that the riscv cpu has the atomic extention?
Or what was the problem

@VynDragon
Copy link
Contributor Author

regarding soc: bflb: re-add ATOMIC_OPERATIONS_C are you sure, that the riscv cpu has the atomic extention? Or what was the problem

Yes, it is supposed to work, but doesn't, so it is a problem for later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants