Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

Plan: Add modules.dmp embedding support

  • Explore repository structure and understand existing implementation
  • Add linker script section for .embedded.modules_dmp in linker/common.ld
  • Add embedding logic in root CMakeLists.txt to handle build-time generation of modules.dmp
  • Add extern symbols in src/main.c for modules_dmp
  • Implement load_embedded_modules_dmp() function in src/main.c
  • Call the new loading function in main() after DMOD initialization
  • Update documentation (README.md and docs/rom-embedding.md)
  • Fix todmp command to use relative paths (commit 5d1bb15)
  • Awaiting user testing in emulation mode

Issue Investigation & Fix

The user reported that modules.dmp was loading (7489 bytes) but had an invalid signature error. After investigation, I found the issue was likely in how todmp was being called in modules/CMakeLists.txt.

Root Cause:
The todmp command was being called with an absolute path for the input directory while WORKING_DIRECTORY was already set to that same directory. This could cause todmp to incorrectly interpret paths or create malformed packages.

Solution (commit 5d1bb15):

  • Changed ${TODMP} modules ${DMBOOT_MODULES_OUT_DIR} ${DMBOOT_MODULES_DMP} to ${TODMP} modules . ${DMBOOT_MODULES_DMP}
  • Using "." for the input directory is more correct since we're already in that directory
  • Simplified related file checks and added proper quoting

This follows the pattern shown in the documentation where todmp is called with relative paths like ./dmf.

Original prompt

This section details on the original issue you should resolve

<issue_title>Dodac wbudowywanie pliku modules.dmp</issue_title>
<issue_description>W folderze modules/ mamy tworzenie pliku modules.dmp - teraz potrzebujemy wbudować go do firmware'u i ładować w main.c. Podobna implementacja już jest dla startup.dmp i user-data, tylko proszę zwróć uwagę, że plik modules.dmp się tworzy na etapie budowania, a nie konfiguracji, oraz że plik modules.dmp może nie istnieć i to nie jest błąd (jeśli nie ma załączyć żadnego modułu, to jest ok to, że go nie ma. </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 20, 2025 10:24
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add embedding of modules.dmp file to firmware Add modules.dmp embedding and runtime loading Nov 20, 2025
Copilot AI requested a review from JohnAmadis November 20, 2025 10:29
add_custom_command(
OUTPUT "${MODULES_DMP_OBJECT}"
COMMAND ${CMAKE_COMMAND} -E echo "Checking for modules.dmp..."
COMMAND bash -c "if [ -f ${MODULES_DMP_FILE} ]; then echo 'Embedding modules.dmp'; ${CMAKE_OBJCOPY} --input-target=binary --output-target=elf32-littlearm --binary-architecture=arm --rename-section .data=.embedded.modules_dmp,alloc,load,readonly,data,contents ${MODULES_DMP_FILE} ${MODULES_DMP_OBJECT}; else echo 'No modules.dmp found, creating empty object'; ${CMAKE_OBJCOPY} --input-target=binary --output-target=elf32-littlearm --binary-architecture=arm --rename-section .data=.embedded.modules_dmp,alloc,load,readonly,data,contents /dev/null ${MODULES_DMP_OBJECT}; fi"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Coś tutaj zmieniasz tutaj przez co ten plik nie chce się załadować. Sprawdź sobie w trybie emulacji jak to działa

[INFO] Loading modules.dmp from ROM: addr=0x80190C0, size=7489 bytes
[INFO] Module is DMP package - loading from package
[INFO] Package buffer added: modules
[WARN] Dmod_Mutex_New interface not implemented
[WARN] Could not create mutex
[ERROR] Cannot load header - invalid signature: 0x%08x
[WARN] dmheap: Module Unknown is not registered.
[ERROR] Failed to load modules.dmp package

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need more information to debug this. The modules.dmp file is being embedded (7489 bytes), but the DMP package format appears corrupted.

Could you check:

  1. Does the modules.dmp file exist in the build directory before embedding?
  2. Can you run ./bin/tools/todmp -l build/modules.dmp to verify the package is valid before embedding?
  3. What module is listed in modules/modules.dmd?

The embedding code I added is identical to how startup.dmp is embedded, so the issue might be with how modules.dmp is being created by the todmp tool in modules/CMakeLists.txt, or there might be a dependency ordering issue.

@JohnAmadis JohnAmadis force-pushed the copilot/embed-modules-dmp-file branch from 5d1bb15 to 4106e02 Compare November 20, 2025 11:58
@JohnAmadis JohnAmadis marked this pull request as ready for review November 20, 2025 17:10
@JohnAmadis JohnAmadis merged commit 900a2d9 into master Nov 20, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dodac wbudowywanie pliku modules.dmp

2 participants