The memory subsystem allows reading and writing raw binary data to various memories and memory-mapped functionalities in the Crazyflie. In the Crazyflie CLI the mem command is used to access the memory subsystem as raw binary data. Some memories also support decoding of the data by using the display parameter.
Note that all command accept both decimal and hexadecimal (prefix 0x) values for
address, size and data parameters.
For documentation on the memory sub system and the various memory types see this link
Most mem subcommands take a memory reference as the first positional argument.
Three forms are accepted:
- Numeric ID — the ID printed by
mem list, e.g.5or0x05. IDs are an enumeration of the memories currently reported by the Crazyflie and may shift if memories are added or removed, so prefer the type-name form when writing guides or scripts. - Type name — a
MemoryTypevariant, e.g.DeckCtrlDFU. Resolves to that memory if exactly one of the type exists. - Type with instance index —
Type:N, e.g.DeckCtrlDFU:0. Required when multiple memories of the same type are present.
If a type name is given but multiple memories of that type are present and no instance index was supplied, the command errors out and prints the valid range of instance indices.
To list all the available memories in the Crazyflie use the following command:
cfcli mem listThis will show an output similar to the one below showing id, type, size and serial (if available):
Memories:
[0] EEPROMConfig size=7k (0x1fff/8191)
[1] Trajectory size=4k (0x1000/4096)
[2] MemoryTester size=4k (0x1000/4096)
[3] DeckCtrl size=2k (0x800/2048) (0x2D0043000550314854363720)
[4] DeckMemory size=1310720k (0x50000000/1342177280)
[5] DeckCtrlDFU size=96k (0x18000/98304)
For machine-readable output, add the global --csv flag:
cfcli --csv mem listid,type,size_bytes,serial
0,EEPROMConfig,8191,
3,DeckCtrl,2048,2D0043000550314854363720
5,DeckCtrlDFU,98304,
Columns: numeric id, type name, decimal size_bytes, and serial (hex
string, empty when the memory has no serial).
mem read defaults to offset 0 and length 32, so a quick peek at a memory
is just:
cfcli mem read DeckCtrlDFUTo read a specific range, use --offset (-s for "seek") and --length
(-n). Both accept decimal or hex (0x...) values:
cfcli mem read DeckCtrlDFU --offset 0x00 --length 0x20
cfcli mem read DeckCtrlDFU -s 0x00 -n 0x20This will read 0x20 (32) bytes from the DeckCtrlDFU memory starting at
address 0x00. The output will look similar to this:
0000: 30 78 42 43 01 3c 02 00 00 00 00 00 00 00 00 e7 0xBC.<..........
0010: e7 e7 e7 e7 ef ff ff ff ff ff ff ff ff ff ff ff ................
Memories can also be addressed by numeric ID:
cfcli mem read 5 -s 0x00 -n 0x20It's also possible to write the data to a file directly using --output (-o):
cfcli mem read DeckCtrlDFU -s 0x00 -n 0x20 -o memory_dump.binTo write raw binary data to the memory use the following command. This will
write the bytes 1, 1, 2 to the EEPROMConfig memory starting at address 0x20.
cfcli mem write EEPROMConfig -s 0x20 --data 0x01,1,0x02It's also possible to write data from a file using --input (-i):
cfcli mem write EEPROMConfig -s 0x20 -i memory_data.binNote: The Crazyflie will most likely not like writing raw random data to memories, so when using this functionality make sure you know what you are doing!
This command is used to interpret and display the content of a memory. Note that not all memories support this functionality.
cfcli mem display EEPROMConfigThis will give an output similar to this:
EEPROM Config:
Radio Channel: 60
Radio Speed: 2 Mbps
Pitch Trim: 0.0000
Roll Trim: 0.0000
Radio Address: [E7, E7, E7, E7, E7]
If no memory is given, an interactive picker is shown.
Below is an example of how to use the raw memory access to bootload the Color
LED deck. Using the DeckMemory type name keeps the commands stable across
firmwares — the numeric ID may differ between Crazyflies (note this only works for one deck
since otherwise there's an offset in the memory address).
# Switch the deck into bootloader mode
cfcli mem write DeckMemory -s 0x1004 --data 0x02
# Write the firmware binary to the deck memory
cfcli mem write DeckMemory -s 0x10000000 -i color-led.bin
# Switch the deck back into application mode
cfcli mem write DeckMemory -s 0x1004 --data 0x01