Build Secrets

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
jimmo
Posts: 1932
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Build Secrets

Post by jimmo » Tue Dec 24, 2019 3:41 am

Definitely prefer the second (i.e. extend the port manifest, rather than duplicating it).

User avatar
devnull
Posts: 454
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Build Secrets - NRF Programming

Post by devnull » Tue Jan 07, 2020 9:05 am

NRF FLASHING


OK, here's some information that will save some time for others trying to program the NRF with Chinese STLINK and The Black Magic Probe:

I have tested with openocd, pyocd and gdb, all are latest versions.

The latest firmware of STLINK does not apear to allow mass erase, so this would fail, the others succeeded for me, however you may have to update the firmware on the STLINK if prompted during the flash process.

Code: Select all

## SOURCE FILES
BTFW61="some_path/micropython/ports/nrf/drivers/bluetooth/s140_nrf52_6.1.1/s140_nrf52_6.1.1_softdevice.hex";
APPHEX="some_path/holyiot_18010-200106-1070984.hex";

## STLINK-V2 - fails during mass erase (stlink v2 not supports ??)
openocd -f interface/stlink.cfg -f target/nrf52.cfg -c init -c "reset init" -c halt -c "nrf mass_erase" -c "program $BTFW61" -c "program $APPHEX verify" -c reset -c exit

## STLINK-V2
TARGET="--target nrf52";
pyocd cmd -c "reset init" $TARGET;
pyocd cmd -c "halt" $TARGET
pyocd erase --mass-erase $TARGET; 
pyocd flash $BTFW61 $TARGET --format hex; 
pyocd flash $APPHEX $TARGET --format hex;
pyocd cmd -c "reset" $TARGET;

## BLACK MAGIC PROBE
gdb -ex "target extended-remote /dev/cu.usbmodem79AD7EA61" -ex "monitor tpwr enable" -ex "monitor swdp_scan" -ex "attach 1" -ex "load $BTFW61" -ex "load $APPHEX" -ex quit;

User avatar
RWLTOK
Posts: 47
Joined: Thu Dec 14, 2017 7:24 pm

Re: Build Secrets - Frozen Manifest

Post by RWLTOK » Mon Mar 02, 2020 1:22 am

Ok. What am I doing wrong?

I have these two lines in my frozen manifest file:

Code: Select all

freeze('../../../../../Micropython-Library-Development/lib/uasyncio')
freeze('../../../../../Micropython-Library-Development/lib/','unittest.py')
Instead of getting a module named uasyncio, I got modules called '__init__, asyn, core, queues, and synchro'.
These are the python files in the directory '../../../../../Micropython-Library-Development/lib/uasyncio'

The module unittest appears fine. How do you include a module that is a subdirectory of files with __init__.py?

Code: Select all

>>> help('modules')
__init__          micropython       ucollections      urandom
__main__          network           uctypes           ure
_onewire          xxxx              uerrno            uselect
asyn              pyb               uhashlib          usocket
builtins          queues            uheapq            ustruct
cmath             stm               uio               utime
core              synchro           ujson             utimeq
framebuf          sys               umachine          uzlib
gc                uarray            unittest
math              ubinascii         uos
Plus any modules on the filesystem
>>>
Rich
devnull wrote:
Tue Dec 24, 2019 3:02 am
If you have a custom manifest file, In order to include the files in the port/modules folder (which are the default frozen files) you need to include the modules folder in your manifest file:

Code: Select all

freeze('$(PORT_DIR)/modules')
OR

Code: Select all

include('$(PORT_DIR)/boards/manifest.py')
freeze("modules")
If you don't then things might be broken, such as on the esp32 you will be unable to access the file system

User avatar
jimmo
Posts: 1932
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Build Secrets

Post by jimmo » Mon Mar 02, 2020 1:44 am

RWLTOK wrote:
Mon Mar 02, 2020 1:22 am
Instead of getting a module named uasyncio, I got modules called '__init__, asyn, core, queues, and synchro'.
These are the python files in the directory '../../../../../Micropython-Library-Development/lib/uasyncio'

The module unittest appears fine. How do you include a module that is a subdirectory of files with __init__.py?
This is a bit weird, but there's an example in ports/esp8266/manifest_release.py

Code: Select all

# uasyncio
freeze("$(MPY_LIB_DIR)/uasyncio", "uasyncio/__init__.py")
freeze("$(MPY_LIB_DIR)/uasyncio.core", "uasyncio/core.py")
It makes sense when you realise that the second argument is also the effective destination path, but I also realise that's a bit non-intuitive.

User avatar
RWLTOK
Posts: 47
Joined: Thu Dec 14, 2017 7:24 pm

Re: Build Secrets

Post by RWLTOK » Mon Mar 02, 2020 2:00 am

Thanks jimmo,
It does make sense.

Rich
jimmo wrote:
Mon Mar 02, 2020 1:44 am
RWLTOK wrote:
Mon Mar 02, 2020 1:22 am
Instead of getting a module named uasyncio, I got modules called '__init__, asyn, core, queues, and synchro'.
These are the python files in the directory '../../../../../Micropython-Library-Development/lib/uasyncio'

The module unittest appears fine. How do you include a module that is a subdirectory of files with __init__.py?
This is a bit weird, but there's an example in ports/esp8266/manifest_release.py

Code: Select all

# uasyncio
freeze("$(MPY_LIB_DIR)/uasyncio", "uasyncio/__init__.py")
freeze("$(MPY_LIB_DIR)/uasyncio.core", "uasyncio/core.py")
It makes sense when you realise that the second argument is also the effective destination path, but I also realise that's a bit non-intuitive.

Post Reply