You can chat about native SDK questions and issues here.

User avatar
By SteveSpencer
#67724 I have installed esp-open-sdk on a Raspberry Pi.
By copying the sdk/Makefile to a ~/projects folder, I can compile the examples if I copy them to a folder in the projects folder.

However, I have now hit a snag. For one project of mine, I need to put some binary data into the app.
I thought this would be straightforward - I have a folder bindata, which contains a data.c wrapper, and a Makefile. The Makefile contains rules to build a binary file, then run xxd to generate a data.h file which is included by the data.c file.

My Makefile looks like this
Code: Select all#
#ifndef PDIR
GEN_LIBS = libdata.a
#endif

PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile

.PHONY: FORCE
FORCE:

data.bin:   root
    mkimage root > data.bin

data.h: data.bin
    xxd -i < data.bin > data.h


while my data.c file is like this:

Code: Select allconst unsigned char __attribute__((section(".irom0.text"))) binary_data_start[]
= {
#include "data.h"
};
const unsigned char __attribute__((section(".irom0.text"))) binary_data_end[] =
{ 0 };

unsigned int binary_data_size = sizeof(binary_data_start);


Now, if I run ./gen_misc.sh in the top level folder, I get a problem that data.h does not exist.
If I add a dependency
Code: Select alldata.c:  data.h

then my data.h file is generated correctly, data.c is not compiled, and the following output appears:
Code: Select allDEPEND: xtensa-lx106-elf-gcc .... data.c
make[1]: Nothing to be done for 'data.c'
make[1]: Leaving directory '/home/pi/projects/prototype/bindata
make: *** No rule to make target 'prototype/.output/eagle/debug/lib/libbindata.a' needed by '.output/eagle/debug/image/eagle.app.v6.out'. Stop.

Obviously, I am missing a trick here. Does anyone have a suggestion to fix this problem?
It recognises that data.h needs to be generated, because of my rule, but because of that same rule, won't then compile data.c!

This is immensely frustrating.

[/code]
User avatar
By SteveSpencer
#67850 Figured out how to achieve my result, even though it isn't ideal.
I moved the generation stuff into a subfolder, and made the generation create the header file, then in the .c file in the existing folder, changed the include to reference the subfolder.


I don't consider it clean, but it does the job. I suspect if I understood Make better, there would be a cleaner way...