tinyuf2
tinyuf2 copied to clipboard
WIP: Support WeAct mini stm32h7
I'm trying to add support for WeAct MiniSTM32H7xx
Pending
- [x] board_self_update
- [x] board_flash_erase_app
- [x] board_flash_write
- [x] board_flash_read ~~board_flash_flush~~
- [x] board_flash_init
- [x] board_flash_size
- [x] board_app_valid
thank you for your effort along with the pending list. For external flash partition make sure you follow the circuitpython stm32 partition scheme https://github.com/adafruit/circuitpython/tree/main/ports/stm/boards . It will require qspi driver to flash external flash, a new port may take quite a bit of time. I will try to help whenever I could. Though currently I don't have this board and it is hard to get anything delivered to my location due to strict lockdown.
I would appreciate any help I can get.
For external flash partition make sure you follow the circuitpython stm32 partition scheme https://github.com/adafruit/circuitpython/tree/main/ports/stm/boards
Looking at the circuitpython repo, I am still quite unsure of what the stm32 partition scheme is and how it would affect tinyuf2. I'm going to try and get the QSPI and SPI memories working first and then continue with the backlog. Ideally I would want all of the memory devices to be available for flash download. (internal + SPI + QSPI)
I have added SPI and QSPI W25Qx drivers from the MiniSTM32H7xx repository. Still in early stages but you can somewhat load code into the QSPI memory and jump to it. I tried loading a simply blinky program to the QSPI flash. The interrupts seem to break after jumping to the QSPI code.
-
Implemented:
board_flash_init
which initializes the SPI flash and disables memory mapped mode on the QSPI flash to allow writes -
Implemented:
board_flash_size
returns 8MB. (Even though the total flash size if 8MB+8MB+64KB). But everything works at the moment. -
Paritally Implemented:
board_app_valid
checks if theReset_Handler
lies in valid flash memory. Stack pointer verification is still pending. -
Partially Implemented:
board_flash_read/board_flash_write
maps memory into 3 segments- QSPI Flash:
0x9000_0000U - 0x907F_FFFF
(8MB) - SPI Flash:
0x6000_0000U - 0x607F_FFFF
(8MB) - PFLASH:
0x0801_0000 - 0x0801_FFFF
(64KB)
- QSPI Flash:
The initial 64KB is for tinyuf2. Programming the PFLASH is still pending since it would require running off of RAM and I'm struggling with getting the board to load code into RAM.
Hey @hathach
Could you check if I'm creating uf2 files right? The code is here
yeah, I think your command is correct, you could try to enable the logging and print out the received address and contents and compare against the bin file to see if it matches. Just fake the actual flashing for testing. e.g https://github.com/adafruit/tinyuf2/blob/master/ports/stm32f4/board_flash.c#L124
Thanks! I finally figured out why the interrupts were not working.
The default SystemInit
restores the VTOR value when the application boots. I couldn't get interrupts to work by modifying SystemInit (maybe vector table in QSPI is a limitation?), so I modified the the application linker script to load the vector table into AXISRAM.
The bootloader works for QSPI flash now, if you compile your application with VECT_TAB_SRAM :)
I have most things working and implemented now, but there are a few things to test (writing data to SPI flash, self-update and uf2 read). I could finish the remaining work along with the review.
The flash driver code isn't very pretty but it works, so I will leave it as is till I can find a portable working replacement. Also the port doesn't handle PFLASH right now (since my board only has the single sector, single bank variant)
I know there hasn't been any movement out here for 2 years, but i recently bought this board and would like having uf2 on it.
- Is there something missing on the code? I could try and implement myself
- Any idea why the firmware worked a couple days back (screen drawing + storage showing up), but it doesnt do either now?
- Flashed other fimrware via stm32dfu between tests
- Blue LED (E3) does light both when USB is connected and pressing RST button
Waiting for a STLink to get delivered, can't provide further info for now
I am not entirely sure as well, PR is still marked as WIP and I kind of forgot about this. @bhav97 do you think this is ready for review and/or merging ?
@hathach , @elpekenin Unfortunately the project I was preparing this for didn't work out and I completely forgot about this WIP-PR.
As for the implementation, all the board_* callouts are available. I believe we can start a review now.
In general I have 2 concerns for this PR
-
I created the ports/stm32h7 but right now there's only a single board that uses this variant. There are other variants that have a different sector size and my additions may need some work to make life easier for people who might want to extend tinyuf2 support in the future.
-
The display and QSPI code is straight out of the WeAct repo and is not documented very well
Any idea why the firmware worked a couple days back (screen drawing + storage showing up), but it doesnt do either now? Flashed other fimrware via stm32dfu between tests Blue LED (E3) does light both when USB is connected and pressing RST button
I believe stm32dfu doesn't support programming external memory so its possible that tinyuf2 was overwritten. (The MCU variant on the board only has a single flash sector of 128K so its not really possible to program the "internal" flash without overwriting tinyuf2. ) You should be able to load firmware to the "external" QSPI flash and RAM just fine.
tinyuf2 was overwritten
Sure, but i mean it doesnt work after flashing the tinyuf2.bin back at it. Which doesnt make any sense in my potato brain
That's not good. Does the blue LED stay on? Does double tap bring up the display?
That's not good. Does the blue LED stay on? Does double tap bring up the display?
Can double check later but Led blinked on both events (plugging wire and pressing button), screen did nothing (not even backlight i think)
Nothing in double press of either button
Went to the mk file to add -DRAMCODE
and give that a try, didnt work either.
But thanks to that i realized there is -flto
, disabled it and everything seems to be working as intended again, weird as heck.
Will now try and compile a .uf2
and report whether loading user's code works
@hathach I have rebased over the latest changes, cleaned up the code and history
@hathach I have rebased over the latest changes, cleaned up the code and history
superb thank you very much, I will review this as soon as I could. There is no problem with H7 having only this as board. We can refactor this later on when new board is added. Thank you very much for updating the PR.
@bhav97 if you are busy, I could make the review changes myself so that we could finally merge this :)
@hathach I have made the requested changes but the underlying issue from #342 is still present. I'll open another PR when I figure it out.
Thank you :)