Only ~500k RAM available when using microPython



  • Hi,

    It seems that we can get only 500k RAM available when using microPython, which is much smaller than the 8MB:

    import sensor, image, lcd, time
    import KPU as kpu
    print(gc.mem_free())  # Got 503008
    

    I am using the latest version of firmware (maixpy_normal.bin) on Sipeed Maxi Dock. Is it possible to free more memory for my application? Thanks!



  • @loboris First of all, thanks for creating MicroPython for K210, it's absolutely awesome! I'm able to get 2.3MB of RAM! I wish it could support KPU module some day (discussed in https://github.com/loboris/MicroPython_K210_LoBo/issues/11), as KPU is basically the reason for me to use K210. I can see there is KPU-related file in the repo (https://github.com/loboris/MicroPython_K210_LoBo/blob/master/k210-freertos/platform/sdk/kendryte-freertos-sdk/lib/bsp/device/kpu.cpp), hope KPU support will come soon!



  • @jackyhu

    I'm not sure why MaixPy has this amount of free memory, it can certainly be larger.
    You can try my MicroPython for K210, it has ~2.3 MB free heap by default and can be configured to to have up to 6 MB.
    Precompiled firmwares are available.
    It is not the same as MaixPy, you can learn about differences on the Wiki pages (info about some newer modules still missing...)

    --[ MicroPython terminal  ver. 5.1.4 ]-- 
    --[ Press ESC twice for command mode ]-- 
    
    M (3653) [K210_MAIN]: Default flash configuration set
    
    RISC-V Kendryte --------------------------------------------- 
     _    _   _____   _   ______    ___   ___   ______   _     _  
    ( )  / ) (___  ) ( ) (  __  )  (   \ /   ) (  __  ) ( )   ( ) 
    | |_/ /   ___| | | | | |  | |  | |\ \ /| | | |__| |  \ \_/ /  
    |  _ )   ( ____) | | | |  | |**| | \_/ | | |  ____)   \   /   
    | | \ \  | |___  | | | |__| |  | |     | | | |         | |    
    (_)  \_) (_____) (_) (______)  (_)     (_) (_)         (_)    
    ------------------------------------------------------------- 
    MicroPython-FreeRTOS by LoBo v1.12.01
    -------------------------------------
    
    MicroPython 1.12.01 (9d99740-dirty) built on 2020-02-06; Sipeed_board with Kendryte-K210
    Type "help()" for more information.
    >>> import gc, machine
    >>> gc.mem_free()
    2325888
    >>> machine.state()
     PLL0: 988000000, PLL1: 806000000,  PLL2:  45066666, SPI3clk: 494000000
     APB0: 247000000, APB1: 247000000,  ACLK: 494000000,    HCLK: 494000000
      CPU: 494000000,  KPU: 403000000
    SRAM0: 494000000 (ACLK/1)
    SRAM1: 494000000 (ACLK/1)
    
    Current SPI Flash speed: 35285714 Hz
    RAM buffer of 4096 bytes at 0x80300000
    OTA not used
    Heaps: FreeRTOS=3068 KB (714 KB free), MPy=2300 KB, other=775 KB
    >>> 
    


  • Hi @tensilestrength, thanks for your prompt reply. I flashed maixpy_v0.3.2_minimum.bin but still only able to get 504576 Bytes of memory using gc.mem_free(). Also tested maixpy_v0.3.2_no_lvgl.bin, maixpy_min_without_IDE.bin and the results are similar. I'll try to post this problem on bbs.sipeed.com.



  • @jackyhu there is another version of maixpy minimal check sipeed
    http://dl.sipeed.com/MAIX/MaixPy/release/maixpy_v0.3.2

    you may post your queries in bbs.sipeed.com for responses about micropython