BrainPad running MicroPython

Showroom for MicroPython related hardware projects.
Target audience: Users wanting to show off their project!
Post Reply
gusissa
Posts: 2
Joined: Tue Nov 06, 2018 2:20 am

BrainPad running MicroPython

Post by gusissa » Tue Nov 06, 2018 3:13 am

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 https://docs.brainpad.com/go-beyond/oth ... 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?

Gus

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: BrainPad running MicroPython

Post by dhylands » Tue Nov 06, 2018 3:31 pm

It looks like examples for most of what you're asking for is available here:
https://github.com/chalei/brainpad-micropython

Or am I misunderstanding what you're asking for?

gusissa
Posts: 2
Joined: Tue Nov 06, 2018 2:20 am

Re: BrainPad running MicroPython

Post by gusissa » Wed Nov 07, 2018 3:05 am

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.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: BrainPad running MicroPython

Post by dhylands » Thu Nov 08, 2018 4:40 am

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,

User avatar
marfis
Posts: 215
Joined: Fri Oct 31, 2014 10:29 am
Location: Zurich / Switzerland

Re: BrainPad running MicroPython

Post by marfis » Thu Nov 08, 2018 5:17 am

there is the mboot bootloader module in the stm32 port, from damien

https://github.com/micropython/micropyt ... 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).

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: BrainPad running MicroPython

Post by scruss » Wed Jun 24, 2020 1:06 pm

I've added temperature sensor reading, fixed one of the LDR scripts and included a much cleaner Timer-based blink:

https://github.com/scruss/brainpad-micropython

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 * adc0.read() / 4096
    degC = (volts - 0.427) / 0.0195
    print('%7.1f degC (%7.3f V)' % (degC, volts))
    sleep(0.5)
Will work on Servo and Buzzer next.

Post Reply