# Is it possible run MicroPython on RTL8720DN(BW16)?

**URL:** <https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167>\
**Category:** MicroPython\
**Tags:** rtl872xd\
**Created:** [March 25, 2022, 3:36pm UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167 "2022-03-25T15:36:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![water-35](https://avatars.discourse-cdn.com/v4/letter/w/51bf81/32.png) [@water-35](https://forum.amebaiot.com/u/water-35)\
**Post date:** [March 25, 2022, 3:36pm UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/1 "2022-03-25T15:36:42Z")

</div>

Or plan to do that?  
RTL8720DN have enough hardware resource to run MicroPython.

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [March 26, 2022, 11:18am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/2 "2022-03-26T11:18:53Z")

</div>

Thanks for your interest, we would also like to run MicroPython on RTL8720DN, but currently it does not have enough RAM to run MicroPython(or lacks of memory optimazation), thus MicroPython is currently only supported on RTL8722DM which has 4MB PSRAM to spare.

If you are interested, you can take a look at the Github hub repo and try to optimize it for RTL8720DN

> **[GitHub - ambiot/ambd\_micropython](https://github.com/ambiot/ambd_micropython)**
>
> Contribute to ambiot/ambd\_micropython development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![mattyt](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/mattyt/32/647_2.png) [@mattyt](https://forum.amebaiot.com/u/mattyt)\
**Post date:** [March 31, 2022, 7:37am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/3 "2022-03-31T07:37:32Z")

</div>

How much RAM is available on this device?

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [March 31, 2022, 8:35am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/4 "2022-03-31T08:35:47Z")

</div>

Same as RTL8722DM, 512K RAM, but only around 456K is available for user

---

<div class="post-metadata">

**Author:** ![mattyt](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/mattyt/32/647_2.png) [@mattyt](https://forum.amebaiot.com/u/mattyt)\
**Post date:** [March 31, 2022, 9:13am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/5 "2022-03-31T09:13:08Z")

</div>

Oh, that ought to be plenty, though it makes perfect sense to make it a lower priority to the RTL8722DM.

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [March 31, 2022, 9:16am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/6 "2022-03-31T09:16:19Z")

</div>

> [@mattyt](#):
>
> lower priority to the RTL8722DM

Yeah, RTL8722DM has 4MB PSRAM, so some of the MicroPython memory are using PSRAM.

But I am also quite interested in how to lower the RAM requirement from MicroPython? besides disabling REPL and RF feature?

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [April 1, 2022, 2:48pm UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/7 "2022-04-01T14:48:08Z")

</div>

Hi @water-35 and @mattyt

I have managed to shift all memory to SRAM and get MicroPython working on BW16 aka RTL8720DN, will let you know once I push it to the github

cheers~

🙂

---

<div class="post-metadata">

**Author:** ![Fedack](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/fedack/32/1076_2.png) [@Fedack](https://forum.amebaiot.com/u/Fedack)\
**Post date:** [July 20, 2022, 11:17am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/8 "2022-07-20T11:17:51Z")

</div>

Did you manage to build a firmware? I am considering using the RTL8720DN because I am very tired of fighting routers due to the lack of 5Ghz support but I am very much used to micropython.

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [July 21, 2022, 2:48am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/9 "2022-07-21T02:48:04Z")

</div>

Yes, and no.

Good news is, MicroPython Ameba port now works flawlessly with BW16 on WiFi related functions, GPIO too.

However, it’s missing pin definitions for other peripherals such as I2C and SPI etc.

you can build the firmware from here

> **[GitHub - ambiot/micropython at ameba](https://github.com/ambiot/micropython/tree/ameba)**
>
> ameba

---

<div class="post-metadata">

**Author:** ![Fedack](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/fedack/32/1076_2.png) [@Fedack](https://forum.amebaiot.com/u/Fedack)\
**Post date:** [August 29, 2022, 11:06am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/10 "2022-08-29T11:06:55Z")

</div>

Hello xi!  
Thank you for your replies.  
Do you have any plans to add those pin definitions in the near future? It would be really nice to end up with full support.  
Also, any way to build this on windows? Or maybe you could be so nice as to provide an already compiled .bin? I have never built one of those firmware.

Also I know I am asking for a lot, but I currently flash things using esptool and I assume this won’t be possible, can you point me toward the direction of where I can learn to flash this firmware?  
Thanks.

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [August 30, 2022, 2:44am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/11 "2022-08-30T02:44:47Z")

</div>

Hi @Fedack

Thanks for your interest, here are to your questions,

> [@Fedack](#):
>
> Do you have any plans to add those pin definitions in the near future?

Yes, it will be added soon~ You can either build the firmware yourself or download the pre-built binary in the future

> [@Fedack](#):
>
> Also, any way to build this on windows?

Yes, currenly building firmware is supported on Windows, Linux and MacOS

> [@Fedack](#):
>
> Or maybe you could be so nice as to provide an already compiled .bin?

Yes, here is the link, simply download the `Firmware and DownloadTool.zip` file from the latest release,

> **[Releases · ambiot/ambd\_micropython](https://github.com/ambiot/ambd_micropython/releases)**
>
> Contribute to ambiot/ambd\_micropython development by creating an account on GitHub.

> [@Fedack](#):
>
> can you point me toward the direction of where I can learn to flash this firmware?

The tool is included in the same zip file as mentioned in the above answer.

---

<div class="post-metadata">

**Author:** ![Fedack](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/fedack/32/1076_2.png) [@Fedack](https://forum.amebaiot.com/u/Fedack)\
**Post date:** [August 30, 2022, 3:04am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/12 "2022-08-30T03:04:19Z")

</div>

Thanks a lot, this answers my questions!  
Do you have an eta on how soon that might be for the pin definitions?

Wonderful work you’re doing 🙂

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [August 30, 2022, 3:11am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/13 "2022-08-30T03:11:35Z")

</div>

we are working towards merging the Ameba MicroPython port into the MicroPython official repository, right now it’s pending code reviews, once this part is done, we will have more resource to add full features for BW16/RTL8720DN 🙂

---

<div class="post-metadata">

**Author:** ![water-35](https://avatars.discourse-cdn.com/v4/letter/w/51bf81/32.png) [@water-35](https://forum.amebaiot.com/u/water-35)\
**Post date:** [September 9, 2022, 8:36am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/14 "2022-09-09T08:36:50Z")

</div>

I try to build ‘RTL8722DM / RTL8722DM\_MINI’ via:

```auto
micropython/ports/ameba> make

```

occur error: region `BD\_RAM\_NS’ overflowed by 224 bytes

> ==========================================================================  
> Use make V=1 or set BUILD\_VERBOSE in your environment to increase build verbosity.  
> This build now supports Cygwin, Linux and MacOS  
> Please specify which board you are building for, currently supported boards:
> 
> - RTL8722DM
> - RTL8722DM\_MINI
> 
> Now building for: RTL8722DM\_MINI  
> …/…/py/mkrules.mk:190: warning: overriding recipe for target ‘submodules’  
> Makefile:423: warning: ignoring old recipe for target ‘submodules’
> 
> …
> 
> /home/mc3/bin/gcc-arm-none-eabi-10.3-2021.10/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld: build/application.axf section `.ram_heap.data' will not fit in region `BD\_RAM\_NS’  
> /home/mc3/bin/gcc-arm-none-eabi-10.3-2021.10/bin/…/lib/gcc/arm-none-eabi/10.3.1/…/…/…/…/arm-none-eabi/bin/ld: region `BD\_RAM\_NS’ overflowed by 224 bytes  
> Memory region Used Size Region Size %age Used  
> IROM: 0 GB 40 KB 0.00%  
> IROM\_NS: 0 GB 216 KB 0.00%  
> DROM\_NS: 0 GB 80 KB 0.00%  
> DROM: 0 GB 16 KB 0.00%  
> ROMBSS\_RAM\_COM: 0 GB 4 KB 0.00%  
> ROMBSS\_RAM\_NS: 0 GB 4 KB 0.00%  
> RSVD\_RAM\_NS: 0 GB 8 KB 0.00%  
> MSP\_RAM\_NS: 0 GB 4 KB 0.00%  
> BD\_RAM\_NS: 487648 B 476 KB 100.05%  
> ROMBSS\_RAM\_S: 0 GB 4 KB 0.00%  
> BOOTLOADER\_RAM\_S: 0 GB 8 KB 0.00%  
> MSP\_RAM\_S: 0 GB 4 KB 0.00%  
> EXTENTION\_SRAM: 0 GB 128 KB 0.00%  
> PSRAM\_NS: 0 GB 4194272 B 0.00%  
> KM0\_BOOT: 0 GB 8160 B 0.00%  
> BACKUP: 0 GB 4 KB 0.00%  
> XIPSYS: 0 GB 4 KB 0.00%  
> KM4\_BOOT: 0 GB 8160 B 0.00%  
> KM0\_IMG2: 0 GB 33554400 B 0.00%  
> KM4\_IMG2: 709080 B 33554400 B 2.11%  
> BTRACE: 0 GB 4 MB 0.00%  
> KM0\_SRAM: 0 GB 64 KB 0.00%  
> RETENTION\_RAM: 0 GB 1 KB 0.00%  
> collect2: error: ld returned 1 exit status  
> make: \*\*\* [Makefile:323: application] Error 1

---

<div class="post-metadata">

**Author:** ![water-35](https://avatars.discourse-cdn.com/v4/letter/w/51bf81/32.png) [@water-35](https://forum.amebaiot.com/u/water-35)\
**Post date:** [September 9, 2022, 8:43am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/15 "2022-09-09T08:43:10Z")

</div>

How to configure to build a RTL8720DN/BW16 firmware?

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [September 9, 2022, 10:17am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/16 "2022-09-09T10:17:13Z")

</div>

Hi , you can edit the default MicroPython heap size in the `main.c` file under the above mentioned path, simply decrease the heap size by 1-2 KB and you should be able to finish compilation and build a working firmware

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [September 9, 2022, 10:19am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/17 "2022-09-09T10:19:12Z")

</div>

Hi, configuration for BW16 is still ongoing as the Ameba port is currently undergone major code re-factoring to simplify the building and editting process, you can expect an update containing all BW16 configuration in the coming 1 week or 2

Thanks for trying MicroPython ameba port and stay tuned for the updates~

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [September 9, 2022, 10:20am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/18 "2022-09-09T10:20:00Z")

</div>

meanwhile, the compiled firmware is already partially working on BW16 on selected modules, such as GPIO and WiFi, you can try them out if you like

---

<div class="post-metadata">

**Author:** ![water-35](https://avatars.discourse-cdn.com/v4/letter/w/51bf81/32.png) [@water-35](https://forum.amebaiot.com/u/water-35)\
**Post date:** [September 9, 2022, 7:51pm UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/19 "2022-09-09T19:51:57Z")

</div>

“heap size” seems should be modify “MP\_HEAP\_SIZE” in “micropython/ports/ameba/mpconfigport.h”? right?

---

<div class="post-metadata">

**Author:** ![xidameng](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/xidameng/32/18_2.png) [@xidameng](https://forum.amebaiot.com/u/xidameng)\
**Post date:** [September 12, 2022, 2:05am UTC](https://forum.amebaiot.com/t/is-it-possible-run-micropython-on-rtl8720dn-bw16/1167/20 "2022-09-12T02:05:30Z")

</div>

Yes, you are right~
