im-tomu / toboot

Bootloader for the EFM32HG Tomu Board
https://tomu.im/
GNU General Public License v3.0
72 stars 28 forks source link

API docs improvements #19

Closed gl-sergei closed 6 years ago

gl-sergei commented 6 years ago

I'll post an issue so that someone better than me at english could fix it.

I think it might be more correct to replace "The EFM32HG has 21 interrupt vectors" with "The EFM32HG has 21 external interrupt vectors".

Referring external interrupt handlers by labels (like VectorN) looks confusing as neither EFM32HG manual nor ARM manual 1 doesn't do that. After some googling I found that it probably comes from ChibiOS where corresponding code was copy-pasted from. Maybe replace labels with offsets or IRQ line numbers?

It would be great to add that in order to implement toboot configuration in Gecko SDK, one must hack on startup_efm32hg.c file and append something like this to the vectors array:

diff --git i/platform/Device/SiliconLabs/EFM32HG/Source/GCC/startup_efm32hg.c w/platform/Device/SiliconLabs/EFM32HG/Sour
ce/GCC/startup_efm32hg.c
index d3eaacee..3714743d 100644
--- i/platform/Device/SiliconLabs/EFM32HG/Source/GCC/startup_efm32hg.c
+++ w/platform/Device/SiliconLabs/EFM32HG/Source/GCC/startup_efm32hg.c
@@ -173,6 +173,8 @@ const pFunc __Vectors[] __attribute__ ((section(".vectors"))) = {
   USART0_TX_IRQHandler,                       /*  18 - USART0_TX       */
   USB_IRQHandler,                       /*  19 - USB       */
   TIMER2_IRQHandler,                       /*  20 - TIMER2       */
+  0x000070b0UL,                            /* toboot cfg flags */
+  0x00046fb0UL,                            /* toboot app flags */

 };
mithro commented 6 years ago

@xobs

gl-sergei commented 6 years ago

There is one more bug in the DOC or in the code.... But probably in both places. DOC is saying:

Set SS to the starting page number to load your program at. .....

Page sizes are 1024 bytes. To maintain compatibility with earlier programs, you may want to set this value to 0x00046fb0, which will explicitly cause programs to be loaded at offset 0x4000.

Which is wrong because 4 * 1024 is 4096 or 0x1000 instead of 0x4000. So, I should put 0x106fb0 instead of 0x00046fb0 to my program to be loaded at offset 0x4000.

But then the bug in toboot chiming in. It actually doesn't multiply that value by 1024, but rather it multiplies it by 4096 (0x1000). Which makes DOC example work :)

xobs commented 6 years ago

All very good points. And you're right, my math was very much off.

API v2.0 should correct the issue with the documentation.

xobs commented 6 years ago

Fixed in 71110977be89c42694b948c6a05a8ada2bd772f5