Page 1 of 1

BrainPad running MicroPython

Posted: Tue Nov 06, 2018 3:13 am
by gusissa
Hello MicroPython experts!

I have been toying around with MicroPython on our BrainPad board. It is an educational board for students, like microbit but on steroids! I am usually a C# developer but there are things I find interesting about Python. I got the basics going though the existing STM32F401 port, and even made a video :D ... ython.html

I am now trying to build libraries for the inputs and outputs on the brainpad (display, multicolor LED, accel, temp...etc.) Is anyone interested in helping out?


Re: BrainPad running MicroPython

Posted: Tue Nov 06, 2018 3:31 pm
by dhylands
It looks like examples for most of what you're asking for is available here:

Or am I misunderstanding what you're asking for?

Re: BrainPad running MicroPython

Posted: Wed Nov 07, 2018 3:05 am
by gusissa
Then there is nothing for me to do! Now that I am looking at it I somewhat remember knowing about it.

Do you know what would be the easiest way to recompile the STM32F401 port to work with a boot loader? (Basically shift the address up 16KB). I haven't had a chance to dig in the code but quickly changed the build to boot from the address need and the code didn't run. I am guessing the code relies on interrupt vectors being in flash at base address.

Any of the other cortex ports work with a bootloader? Maybe I can use it as a reference.

Re: BrainPad running MicroPython

Posted: Thu Nov 08, 2018 4:40 am
by dhylands
It should be possible to make the stm port work with a bootloader, but I don' t think anybody has done it yet.

The stm32 has a builtin bootloader (DFU) which is probably why nobody has really put any effort into integrating another one.

The flash layout goes something like:

16K - ISRs and some code
112K flash filesystem
remainder of flash for code.

Everything in the first 16k would need to be combined with the "remainder of flash for code". IIRC there is a register in the NVIC which allows the ISR location to be moved. The bootloader is probably pointing this to 16K boundary which is the first block of the flash filesystem. The bootloader would also need to be aware of MicroPython being at the 128K mark instead of the 16K mark.

It might be possible to put the MicroPython ISRs etc in the 2nd 16K block, but then the filesystem would need to be shrunk by 16K and the code for the filesystem storage would need to be modified appropriately,

Re: BrainPad running MicroPython

Posted: Thu Nov 08, 2018 5:17 am
by marfis
there is the mboot bootloader module in the stm32 port, from damien ... tm32/mboot

basically implements DFU over USB and I2C, with support to write external SPI chips.

I think he might use this one in his upcoming new pyboard devices, thats why nobody has using it so far.

But you can get a good impression of how its being done (basically look at main.c).

Re: BrainPad running MicroPython

Posted: Wed Jun 24, 2020 1:06 pm
by scruss
I've added temperature sensor reading, fixed one of the LDR scripts and included a much cleaner Timer-based blink:

Not sure if I have the calibration of the mcp9701a is quite right: seems to be reading rather high:

Code: Select all

from pyb import ADC,Pin
from time import sleep
adc0 = ADC(Pin('B0'))

while True:
    volts = 3.3 * / 4096
    degC = (volts - 0.427) / 0.0195
    print('%7.1f degC (%7.3f V)' % (degC, volts))
Will work on Servo and Buzzer next.