-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify the packaging scripts and add packaging support for SG2044 fir…
…mware
- Loading branch information
1 parent
7d5fa90
commit a60c5e4
Showing
16 changed files
with
1,969 additions
and
19 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
if [ "$1" = "mango" ];then | ||
gcc $RV_SCRIPTS_DIR/make_xml.c -DSG2042 -o $RV_FIRMWARE_INSTALL_DIR/make_xml | ||
gcc $RV_SCRIPTS_DIR/pack/pack.c -DSG2042 -o $RV_FIRMWARE_INSTALL_DIR/pack | ||
RELEASED_NOTE_MD="$RELEASED_NOTE_PATH/sg2042_release_note.md" | ||
cp $RV_FIRMWARE/fip.bin $RV_FIRMWARE_INSTALL_DIR/ | ||
elif [ "$1" = "sg2044" ];then | ||
gcc $RV_SCRIPTS_DIR/make_xml.c -DSG2044 -o $RV_FIRMWARE_INSTALL_DIR/make_xml | ||
gcc $RV_SCRIPTS_DIR/pack/pack.c -DSG2044 -o $RV_FIRMWARE_INSTALL_DIR/pack | ||
RELEASED_NOTE_MD="$RELEASED_NOTE_PATH/sg2044_release_note.md" | ||
cp $RV_FIRMWARE/fsbl.bin $RV_FIRMWARE_INSTALL_DIR/ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <sys/stat.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <stdint.h> | ||
#include "pack/ezxml/ezxml.h" | ||
#include "pack/ezxml/ezxml.c" | ||
|
||
#define BUFFERSIZE 16 | ||
|
||
#define SG2042_DTB_OFFSET 0x601000 | ||
#define SG2042_DTB_LOADER "0x20000000" | ||
#define SG2044_DTB_OFFSET 0x500000 | ||
#define SG2044_DTB_LOADER "0x88000000" | ||
|
||
void format_xml(const char *input,char *output){ | ||
const char *ptr = input; | ||
char *out_ptr = output; | ||
int indent=0,marked=0; | ||
while(*ptr){ | ||
if(*ptr=='>'){ | ||
if(*(ptr+1)=='<'){ | ||
if(*(ptr+2)=='/'){ | ||
*out_ptr++=*ptr++; | ||
indent-=1; | ||
marked=1; | ||
} | ||
else{ | ||
if(marked){ | ||
*out_ptr++=*ptr++; | ||
marked=0; | ||
} | ||
else{ | ||
indent+=1; | ||
*out_ptr++=*ptr++; | ||
} | ||
} | ||
*out_ptr++='\n'; | ||
memset(out_ptr,'\t',indent); | ||
out_ptr+=indent; | ||
} | ||
else{ | ||
marked=1; | ||
*out_ptr++=*ptr++; | ||
} | ||
}else{ | ||
*out_ptr++=*ptr++; | ||
} | ||
} | ||
*out_ptr = '\0'; | ||
} | ||
|
||
int ezxml_set_element(ezxml_t parent,char *child,char *name,char *offset,char *loader,char* size){ | ||
ezxml_t component=ezxml_add_child(parent,child,0); | ||
if (component==NULL){ | ||
ezxml_free(parent); | ||
return -1; | ||
} | ||
if(name){ | ||
ezxml_set_txt(ezxml_add_child(component, "name", 0), name); | ||
ezxml_set_txt(ezxml_add_child(component, "file", 0), name); | ||
} | ||
if(offset){ | ||
ezxml_set_txt(ezxml_add_child(component,"offset" , 0), offset); | ||
} | ||
if(loader){ | ||
ezxml_set_txt(ezxml_add_child(component,"loader" , 0), loader); | ||
} | ||
if(size){ | ||
ezxml_set_txt(ezxml_add_child(component,"size" , 0), size); | ||
} | ||
return 0; | ||
} | ||
|
||
void ezxml_set_component(ezxml_t parent,char *comp_name,char *comp_offset,char *comp_loader){ | ||
ezxml_set_element(parent,"component",comp_name,comp_offset,comp_loader,NULL); | ||
} | ||
|
||
int main(int argc, char* argv[]) { | ||
|
||
struct stat file_stat; | ||
int ret,i; | ||
char* file_name,*out_put; | ||
char *ld_dtb; | ||
char sflash_offset[argc-1][BUFFERSIZE]; | ||
uint64_t of_dtb; | ||
ezxml_t xml = ezxml_new("firmware"); | ||
if (xml==NULL){ | ||
printf("generate xml file failed!"); | ||
return -1; | ||
} | ||
// generate xml file | ||
#ifdef SG2042 | ||
of_dtb=SG2042_DTB_OFFSET; | ||
ld_dtb=SG2042_DTB_LOADER; | ||
ezxml_set_txt(ezxml_add_child(xml, "name", 0), "SG2042"); | ||
ezxml_set_txt(ezxml_add_child(xml, "size", 0), "0x4000000"); | ||
// add efie | ||
ezxml_set_element(xml,"efie",NULL,"0x600000",NULL,"4096"); | ||
//add fip.bin | ||
ezxml_set_element(xml,"fip","fip.bin","0x00030000",NULL,NULL); | ||
//add zsbl.bin | ||
ezxml_set_component(xml,"zsbl.bin","0x2a00000","0x40000000"); | ||
//add fw_dynamic.bin | ||
ezxml_set_component(xml,"fw_dynamic.bin","0x660000","0x00000000"); | ||
//add riscv64_Image | ||
ezxml_set_component(xml,"riscv64_Image","0x6b0000","0x02000000"); | ||
//add initrd.img | ||
ezxml_set_component(xml,"initrd.img","0x2b00000","0x30000000"); | ||
out_put="sg2042-layout.xml"; | ||
#elif defined(SG2044) | ||
of_dtb=SG2044_DTB_OFFSET; | ||
ld_dtb=SG2044_DTB_LOADER; | ||
ezxml_set_txt(ezxml_add_child(xml, "name", 0), "SG2044"); | ||
ezxml_set_txt(ezxml_add_child(xml, "size", 0), "0x4000000"); | ||
// add efie | ||
ezxml_set_element(xml,"efie",NULL,"0x80000",NULL,"4096"); | ||
//add zsbl.bin | ||
ezxml_set_component(xml,"zsbl.bin","0x2f0000","0x40000000"); | ||
//add fsbl.bin | ||
ezxml_set_component(xml,"fsbl.bin","0x81000","0x7010080000"); | ||
//add fw_dynamic.bin | ||
ezxml_set_component(xml,"fw_dynamic.bin","0x15d000","0x80000000"); | ||
//add SG2044.fd | ||
ezxml_set_component(xml,"SG2044.fd","0x600000","0x80200000"); | ||
out_put="sg2044-layout.xml"; | ||
#endif | ||
|
||
// add device-tree | ||
for (i=0;i<argc-1;i++){ | ||
sprintf(sflash_offset[i], "0x%lX", of_dtb); | ||
file_name=argv[i+1]; | ||
ret=stat(file_name,&file_stat); | ||
if (ret || !file_stat.st_size) { | ||
printf("can't get file %s size %ld\n", file_name,file_stat.st_size); | ||
return -1; | ||
} | ||
ezxml_set_component(xml,file_name,sflash_offset[i],ld_dtb); | ||
of_dtb += file_stat.st_size; | ||
} | ||
FILE *fp = fopen(out_put, "w"); | ||
if (fp==NULL){ | ||
ezxml_free(xml); | ||
printf("can't create and open %s !",out_put); | ||
return -1; | ||
} | ||
else if (fp) { | ||
// ret=fprintf(fp, "<?xml version=\"1.0\"?>\n"); | ||
const char *raw_xml = ezxml_toxml(xml); | ||
char formatted_xml[8192]; | ||
format_xml(raw_xml, formatted_xml); | ||
fprintf(fp, "%s", formatted_xml); | ||
fclose(fp); | ||
} | ||
ezxml_free(xml); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pack | ||
pack.elf | ||
*.o | ||
*.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# PC Pack Tools | ||
This tool is used to pack binary. | ||
|
||
# How to compile | ||
just gcc. | ||
|
||
# How to use | ||
pack *.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Makefile | ||
# | ||
# Copyright 2005 Aaron Voisine <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
CC = gcc | ||
AR = ar | ||
RM = rm -f | ||
CFLAGS = -Wall -O2 | ||
DEBUG_CFLAGS = -O0 -g | ||
OBJS = ezxml.o | ||
LIB = libezxml.a | ||
TEST = ezxmltest | ||
ifdef NOMMAP | ||
CFLAGS += -D EZXML_NOMMAP | ||
endif | ||
ifdef DEBUG | ||
CFLAGS += $(DEBUG_CFLAGS) | ||
endif | ||
|
||
all: $(LIB) | ||
|
||
$(LIB): $(OBJS) | ||
$(AR) rcs $(LIB) $(OBJS) | ||
|
||
nommap: CFLAGS += -D EZXML_NOMMAP | ||
nommap: all | ||
|
||
debug: CFLAGS += $(DEBUG_CFLAGS) | ||
debug: all | ||
|
||
test: CFLAGS += $(DEBUG_CFLAGS) | ||
test: $(TEST) | ||
|
||
$(TEST): CFLAGS += -D EZXML_TEST | ||
$(TEST): $(OBJS) | ||
$(CC) $(CFLAGS) -o $@ $(OBJS) | ||
|
||
ezxml.o: ezxml.h ezxml.c | ||
|
||
.c.o: | ||
$(CC) $(CFLAGS) -c -o $@ $< | ||
|
||
clean: | ||
$(RM) $(OBJS) $(LIB) $(TEST) *~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Makefile | ||
# | ||
# Copyright 2004, 2005 Aaron Voisine <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
CC = gcc | ||
AR = ar | ||
RM = rm -f | ||
CFLAGS = -Wall -O2 | ||
OBJS = ezxml.o | ||
LIB = libezxml.a | ||
TEST = ezxmltest | ||
|
||
.if defined(NOMMAP) || make(nommap) | ||
CFLAGS += -D EZXML_NOMMAP | ||
.endif | ||
.if defined(DEBUG) || make(debug) || make(test) | ||
CFLAGS += -O0 -g | ||
.endif | ||
.if make($(TEST)) || make(test) | ||
CFLAGS += -D EZXML_TEST | ||
.endif | ||
|
||
all: $(LIB) | ||
|
||
$(LIB): $(OBJS) | ||
$(AR) rcs $(LIB) $(OBJS) | ||
|
||
test: $(TEST) | ||
|
||
debug: all | ||
|
||
nommap: all | ||
|
||
$(TEST): $(OBJS) | ||
$(CC) $(CFLAGS) -o $@ $(OBJS) | ||
|
||
ezxml.o: ezxml.h ezxml.c | ||
|
||
.c.o: | ||
$(CC) $(CFLAGS) -c -o $@ $< | ||
|
||
clean: | ||
$(RM) $(OBJS) $(LIB) $(TEST) *~ |
Oops, something went wrong.