bbcmicrobit / bbcmicrobit/micropython
How to make a Frozen module under current master branch
- Dominant language
- C
- Stars
- 646
- Forks
- 290
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
After read this [issue #347](https://github.com/bbcmicrobit/micropython/issues/347) , I began to freeze my module into the hex file. Although it creates a hex file successfully, but when I flashed it in my micro:bit and tried to import it, no module was found. I have tried help('modules') in REPL, my module is just not there.
I have followed the instruction of Simon Cragg.
1. Use micropython v1.7 's make-frozen.py to freeze my module to a .c file. (I put a .py file in a folder with same name and freeze the folder)
2. Add this .c file to micropython/source/py
3. Add `#define MICROPY_MODULE_FROZEN (1)` to micropython/inc/microbit/mpconfigport.h
4. `yotta build` which returns me a microbit-micropython.hex
This is what in my `build/bbc-microbit-classic-gcc-nosd/source/microbit-micropython.map` file.
It seems that my c module file ttt.c has been compiled
```
.text 0x0000000000000000 0x0 source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.data 0x0000000000000000 0x0 source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.bss 0x0000000000000000 0x0 source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.rodata.mp_frozen_content
0x0000000000000000 0x75 source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.rodata.mp_frozen_names
0x0000000000000000 0x6 source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.rodata.mp_frozen_sizes
0x0000000000000000 0x4 source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.debug_info 0x0000000000000000 0x103 source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.debug_abbrev 0x0000000000000000 0x5b source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.debug_aranges
0x0000000000000000 0x18 source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.debug_line 0x0000000000000000 0x9c source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.debug_str 0x0000000000000000 0x18f source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.comment 0x0000000000000000 0x32 source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
.ARM.attributes
0x0000000000000000 0x31 source/CMakeFiles/microbit-micropython.dir/home/pd/Downloads/bbc/source/py/ttt.c.o
```
ttt is not in hex file, I guess.
I'm using the code on master branch. Below is the ttt.py content. I compile the code on ubuntu.
```
class say:
def __init__(self, words):
self.words = words
def say(self):
print(self.words)
```
Please Could someone give me some advise? I have totally no idea about it.
Many Thanks to you !
Pye
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with issue #347 and the current make-frozen.py workflow, then inspect ttt.c and inc/microbit/mpconfigport.h alongside the yotta build configuration. Compare the generated frozen sections in the map file with the flashed hex and verify the result using help('modules') and import ttt in the micro:bit REPL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- build-system, embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100