Page 1 of 1

How can I start with the 'minimal' directory?

Posted: Mon Jan 04, 2016 8:25 am
by tego06
Hello,everyone! I am a beginner for learning MicroPython,also a beginner for learning microcontroler.

I haved successfully port the 'stmhal' version to my blank stm32f405 chip and enjoyed the interactive programming. I want to reduce the peripherals and start with the 'minimal' version. Since I am a beginner and there's no tutorial for 'minimal' port so I don't know how to start. :(

Here are my questions:
1:How can I port the 'minimal' version to my blank stm32f405 chip?(which codes do I have to modify?) I just need the REPL and want to reduce the peripherals.

2.The Makefile in the 'minimal' doesn't create the .dfu file (the 'stmhal' version does ). Then I followed this http://forum.micropython.org/viewtopic. ... imal#p3268 to create the .dfu file.
But when I did this in the command line "sudo dfu-util -a 0 -d 0483:df11 -s 0x08000000 -D build/firmware1.dfu"
It returned "dfu-util: This is a DfuSe file, not meant for raw download"
How can I fix this?

Thanks a lot!

Re: How can I start with the 'minimal' directory?

Posted: Mon Jan 04, 2016 1:02 pm
by Damien
Hi!

I would suggest sticking with the stmhal directory and just removing things one-by-one until it's minimal enough for you. That's the easiest way, and if you break something it's easy to revert to a known working state.

Start by looking at stmhal/mpconfigport.h and disabling things you don't need in there. See also stmhal/boards/PYBV10/mpconfigboard.h.

You can also just remove files from the Makefile that you don't want, eg can.c. Then also remove the link to this module in stmhal/modpyb.c.

Good luck!

Re: How can I start with the 'minimal' directory?

Posted: Tue Jan 05, 2016 9:10 am
by tego06
Thanks for the quick reply! :) I can remove things as I want now!

But what about the 2nd question?
How can I create a .dfu file and download it to the chip from the .elf file that created from the 'minimal' version?
Why is that in the 'stmhal',only need to extract 3 sections (.isr_vector .text .data) to create 2 bin files and merge them into a .dfu file? :?

Re: How can I start with the 'minimal' directory?

Posted: Wed Jan 06, 2016 12:18 pm
by Damien
tego06 wrote: But what about the 2nd question?
How can I create a .dfu file and download it to the chip from the .elf file that created from the 'minimal' version?
Why is that in the 'stmhal',only need to extract 3 sections (.isr_vector .text .data) to create 2 bin files and merge them into a .dfu file? :?
You get the error message because you used the "-s" option with a .dfu file. Dfu files already have the address specified in them, so don't use -s.

To create a .dfu file from a .elf file look at how stmhal/Makefile does it (run make V=1 to see exact commands use). Basically you need to use objcopy to extract the data from the .elf, then tools/dfu.py to merge the output of objcopy into a single .dfu file.

The reason there are 2 separate memory sections (0x08000000 and 0x08020000) is because the filesystem lives in between these addresses in flash.

You need .isr_vector for the ISR table, .text for the code, and .data for the data initialisation. No other linker sections are needed.

Re: How can I start with the 'minimal' directory?

Posted: Thu Jan 07, 2016 12:44 am
by tego06
Sorry to bother you again :oops:

When I removed '-s' option I got this "dfu-util: Last page at 0x07ffffff is not writeable".
Is there any other option that need to be set up? :?