Chat freely about anything...

User avatar
By sfranzyshen
#9587
lethe wrote:No, the compiler will do this for you, since the hex chars are not quoted. The resulting program will have an array, which is a 1:1 representation of your file's content.

but the final resulting file is so much larger then the original ... original html.gz = 44K ... after hexdump html.hex = 217K ... that is larger then the base64 file html.b64 = 59K ... I am going to guess that that size will be smaller once compiled ... but how much smaller? I think I may have found another solution that maintains the original gzip file size ...

Code: Select allxtensa-lx106-elf-objcopy -I binary -B xtensa -O elf32-xtensa-le html.gz html.o

xtensa-lx106-elf-objdump -x html.o

html.o:     file format elf32-xtensa-le
html.o
architecture: xtensa, flags 0x00000010:
HAS_SYMS
start address 0x00000000

Xtensa header:

Machine     = Base
Insn tables = false
Literal tables = false

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .data         0000ad09  00000000  00000000  00000034  2**0
                  CONTENTS, ALLOC, LOAD, DATA
SYMBOL TABLE:
00000000 l    d  .data   00000000 .data
00000000 g       .data   00000000 _binary_html_gz_start
0000ad09 g       .data   00000000 _binary_html_gz_end
0000ad09 g       *ABS*   00000000 _binary_html_gz_size

as we can see that once linked with the rest of the program, we should be able to access the data ...

extern char _binary_html_gz_start[];
extern char _binary_html_gz_end[];
#define SIZE_OF_HTML (_binary_html_gz_end - _binary_html_gz_start)

...

foo(_binary_html_gz_start[i]);



lethe wrote:If you want to do more than to serve a single file, you should really have a look at esphttpd


Yes! I have looked into esphttpd as well as WebBase ... both handle httpd server very well ... neither support https (ssl). I am starting this project to create a lighterweight alternative to the full blown web server environment. my main goal here is to provide a small web app configuration utility ... that can be added to various projects ... starting with this ... http://www.esp8266.com/viewtopic.php?f=6&t=1441 ...
User avatar
By lethe
#9588
sfranzyshen wrote:but the final resulting file is so much larger then the original ... original html.gz = 44K ... after hexdump html.hex = 217K ... that is larger then the base64 file html.b64 = 59K ... I am going to guess that that size will be smaller once compiled ... but how much smaller?

tested with random data (on x86_64, but should not make much of a difference):
data = 50k
source = 301k
compiled = 57K (a file with an empty main function has 6.4K)
User avatar
By sfranzyshen
#9592
lethe wrote:tested with random data (on x86_64, but should not make much of a difference):
data = 50k
source = 301k
compiled = 57K (a file with an empty main function has 6.4K)


that's awesome! ... what hexdump paramaters are you using? Here is what I have been using to perform test ...

hexdump -v -e '16/1 "0x%x," "\n"' html.gz > html.hex

I am going to experiment with both methods to see which one has a better outcome ...

thanks for your input! :D
User avatar
By lethe
#9595
sfranzyshen wrote:that's awesome! ... what hexdump paramaters are you using?

I didn't bother with hexdump, I used a simple ruby script:
Code: Select all#!/usr/bin/ruby

print "int main(void) {\n\tchar foo[] = {"
STDIN.each_byte{|b| printf "0x%02X, ", b}
print "};\n\treturn 0;\n}"