Error : " 'bss' will not fit into region 'SRAM' " on stml552zeq board

Hi @areusch,

I am trying to deploy a basic perceptron on stml552zeq board but I am getting following error from the build process.

[ 96%] Linking CXX executable zephyr_prebuilt.elf /home/vagrant/zephyr-sdk/arm-zephyr-eabi/bin/…/lib/gcc/arm-zephyr-eabi/10.2.0/…/…/…/…/arm-zephyr-eabi/bin/ld: zephyr_prebuilt.elf section bss' will not fit in region SRAM’ /home/vagrant/zephyr-sdk/arm-zephyr-eabi/bin/…/lib/gcc/arm-zephyr-eabi/10.2.0/…/…/…/…/arm-zephyr-eabi/bin/ld: section .intList VMA [0000000020030000,0000000020030117] overlaps section bss VMA [00000000200001f0,000000002003ea5b] /home/vagrant/zephyr-sdk/arm-zephyr-eabi/bin/…/lib/gcc/arm-zephyr-eabi/10.2.0/…/…/…/…/arm-zephyr-eabi/bin/ld: region `SRAM’ overflowed by 63392 bytes collect2: error: ld returned 1 exit status zephyr/CMakeFiles/zephyr_prebuilt.dir/build.make:119: recipe for target ‘zephyr/zephyr_prebuilt.elf’ failed make[2]: *** [zephyr/zephyr_prebuilt.elf] Error 1 CMakeFiles/Makefile2:2543: recipe for target ‘zephyr/CMakeFiles/zephyr_prebuilt.dir/all’ failed make[1]: *** [zephyr/CMakeFiles/zephyr_prebuilt.dir/all] Error 2 make: *** [all] Error 2 Makefile:90: recipe for target ‘all’ failed

To give you more information, I am providing the code snippet below.

def _make_session(temp_dir, zephyr_board, west_cmd, mod):

    config_main_stack_size = None

    proj_dir = temp_dir + "/project"

    if config_main_stack_size is not None:
        project_options["config_main_stack_size"] = config_main_stack_size
    
    # Remove existing project directory containing board specific build files
    if os.path.isdir(proj_dir):
        shutil.rmtree(proj_dir, ignore_errors=True)
    project_options = {
        "project_type": "host_driven",
        "west_cmd": west_cmd,
        "verbose": False,
        "zephyr_board": zephyr_board,
    }
    project = tvm.micro.generate_project(
        temp_dir,
        mod,
        proj_dir,
        project_options,
    )
        
            
    project.build()
    project.flash()
    return tvm.micro.Session(project.transport(), timeout_override=tvm.micro.transport.debug_transport_timeouts(30))

TARGET = tvm.target.target.micro("mps2_an521")
BOARD = "nucleo_l552ze_q"

with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
        # Compiles the relay model passed into C code using TVM compiler
        c_mod = relay.build(mod, target=TARGET, runtime=RUNTIME, params=params)

with _make_session(project_dir, BOARD, "west", c_mod) as session:
        #Use debug executor mode to enable latency profiling from on chip timer.
        #Dump the logs in a json file.
        graph_mod = tvm.micro.create_local_debug_executor(c_mod.get_graph_json(), session.get_system_lib(), session.device, dump_root= temp_file_directory)
        graph_mod.set_input(**c_mod.get_params())    
        graph_mod.run() # Executes the network on the chip
        tvm_output = graph_mod.get_output(0).asnumpy()# Extracts output from the on chip memory

Do you have any idea what might cause this issue?

@asnecemnnit this typically happens when you’ve allocated too much SRAM to global variables. I’m not entirely sure why this is happening with this board, since it has 512kB SRAM. However, it’s possible that Zephyr could configure the RAM in some default way so that less than 512kB are actually available to you. The majority of the global memory allocated by the host-driven project is here. You might try reducing that by about 65kB and see if that helps.

cc @gromero in case he knows more about this board’s Zephyr config.

@asnecemnnit Hi. I faced it once in the past and I resolved it by updating my Zephyr SDK version. It seems you’re using the 0.12.3 version. Could you please update to the 0.13.2 version and try it again?

@gromero, I updated zephyr-sdk to 0.13.2 version, but still facing the same error. Was there anything else you changed to resolve it?

@asnecemnnit Nope, unfortunately no. Let me take a closer look tho. Could you file an issue at TVM’s github, please, and post the logs there? [microTVM] Error: 'bss’ will not fit into region ‘SRAM’ on stml552zeq board