Discussion:
[PATCH 1/6] Replace a magic number with a define
Timo Juhani Lindfors
2011-11-04 14:22:40 UTC
Permalink
This patch makes it easier to modify kernel source list in the future,
it does not cause any functional changes.
---
src/cpu/s3c2442/gta02.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/cpu/s3c2442/gta02.c b/src/cpu/s3c2442/gta02.c
index 13be2ac..7dba31b 100644
--- a/src/cpu/s3c2442/gta02.c
+++ b/src/cpu/s3c2442/gta02.c
@@ -36,6 +36,7 @@
#define GTA02_DEBUG_UART 2
#define PCF50633_I2C_ADS 0x73
#define BOOST_TO_400MHZ 1
+#define KERNEL_SOURCE_NAND_INDEX 3

static int battery_condition_reasonable = 0;

@@ -363,7 +364,7 @@ void port_init_gta02(void)

/* fix up the true start of kernel partition */

- ((struct board_api *)&board_api_gta02)->kernel_source[3].
+ ((struct board_api *)&board_api_gta02)->kernel_source[KERNEL_SOURCE_NAND_INDEX].
offset_blocks512_if_no_partition = nand_dynparts[2].true_offset;

}
@@ -628,7 +629,7 @@ char * append_device_specific_cmdline_gta02(char * cmdline)
* lie that we are in NAND context... GTA02 specific
* all filesystem access is completed before we are called
*/
- this_kernel = &board_api_gta02.kernel_source[3];
+ this_kernel = &board_api_gta02.kernel_source[KERNEL_SOURCE_NAND_INDEX];

if (!ext2fs_mount()) {
puts("Unable to mount ext2 filesystem\n");
@@ -727,7 +728,7 @@ const struct board_api board_api_gta02 = {
.filepath = "boot/uImage-GTA02.bin",
.commandline_append = " root=/dev/mmcblk0p3 rootdelay=1 ",
},
- [3] = {
+ [KERNEL_SOURCE_NAND_INDEX] = {
.name = "NAND Kernel",
.block_read = nand_read_ll,
/* NOTE offset below is replaced at runtime */
--
1.7.2.5
Timo Juhani Lindfors
2011-11-04 14:22:41 UTC
Permalink
If BUILD_HEAD and BUILD_BRANCH are passed as an argument the build no
longer calls git. This makes building qi possible from a source
tarball that no longer has ".git" without having to fear that git
finds some unrelated ".git" in some parent directory.
---
Makefile | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 5421478..5f4e779 100644
--- a/Makefile
+++ b/Makefile
@@ -18,8 +18,8 @@ include config.mk

BUILD_DATE := $(shell date --iso-8601=seconds)
BUILD_HOST := $(shell hostname)
-BUILD_BRANCH := $(shell git branch | grep ^\* | cut -d' ' -f2)
-BUILD_HEAD := $(shell git show --pretty=oneline | head -n1 | cut -d' ' -f1 | cut -b1-16)
+BUILD_BRANCH ?= $(shell git branch | grep ^\* | cut -d' ' -f2)
+BUILD_HEAD ?= $(shell git show --pretty=oneline | head -n1 | cut -d' ' -f1 | cut -b1-16)
BUILD_VERSION := ${BUILD_BRANCH}_${BUILD_HEAD}

LDS = src/cpu/$(CPU)/qi.lds
--
1.7.2.5
Timo Juhani Lindfors
2011-11-04 14:22:43 UTC
Permalink
This patch makes it possible to choose between two different kernels
without having to have two SD card partitions.
---
src/cpu/s3c2442/gta02.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/cpu/s3c2442/gta02.c b/src/cpu/s3c2442/gta02.c
index 7dba31b..d3ca634 100644
--- a/src/cpu/s3c2442/gta02.c
+++ b/src/cpu/s3c2442/gta02.c
@@ -36,7 +36,7 @@
#define GTA02_DEBUG_UART 2
#define PCF50633_I2C_ADS 0x73
#define BOOST_TO_400MHZ 1
-#define KERNEL_SOURCE_NAND_INDEX 3
+#define KERNEL_SOURCE_NAND_INDEX 4

static int battery_condition_reasonable = 0;

@@ -711,6 +711,15 @@ const struct board_api board_api_gta02 = {
.commandline_append = " root=/dev/mmcblk0p1 rootdelay=1 ",
},
[1] = {
+ .name = "SD Card EXT2 P1 Kernel",
+ .block_init = sd_card_init_gta02,
+ .block_read = sd_card_block_read_gta02,
+ .partition_index = 1,
+ .filesystem = FS_EXT2,
+ .filepath = "boot/uImage-GTA02.bin.2",
+ .commandline_append = " root=/dev/mmcblk0p1 rootdelay=1 ",
+ },
+ [2] = {
.name = "SD Card EXT2 P2 Kernel",
.block_init = sd_card_init_gta02,
.block_read = sd_card_block_read_gta02,
@@ -719,7 +728,7 @@ const struct board_api board_api_gta02 = {
.filepath = "boot/uImage-GTA02.bin",
.commandline_append = " root=/dev/mmcblk0p2 rootdelay=1 ",
},
- [2] = {
+ [3] = {
.name = "SD Card EXT2 P3 Kernel",
.block_init = sd_card_init_gta02,
.block_read = sd_card_block_read_gta02,
--
1.7.2.5
Timo Juhani Lindfors
2011-11-04 14:22:45 UTC
Permalink
Tested with 2.3 MB initrd created using debian mkinitramfs.
---
src/cpu/s3c2442/gta02.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/cpu/s3c2442/gta02.c b/src/cpu/s3c2442/gta02.c
index d3ca634..935de8b 100644
--- a/src/cpu/s3c2442/gta02.c
+++ b/src/cpu/s3c2442/gta02.c
@@ -708,6 +708,7 @@ const struct board_api board_api_gta02 = {
.partition_index = 1,
.filesystem = FS_EXT2,
.filepath = "boot/uImage-GTA02.bin",
+ .initramfs_filepath = "boot/initrd-GTA02.bin",
.commandline_append = " root=/dev/mmcblk0p1 rootdelay=1 ",
},
[1] = {
@@ -717,6 +718,7 @@ const struct board_api board_api_gta02 = {
.partition_index = 1,
.filesystem = FS_EXT2,
.filepath = "boot/uImage-GTA02.bin.2",
+ .initramfs_filepath = "boot/initrd-GTA02.bin.2",
.commandline_append = " root=/dev/mmcblk0p1 rootdelay=1 ",
},
[2] = {
@@ -726,6 +728,7 @@ const struct board_api board_api_gta02 = {
.partition_index = 2,
.filesystem = FS_EXT2,
.filepath = "boot/uImage-GTA02.bin",
+ .initramfs_filepath = "boot/initrd-GTA02.bin",
.commandline_append = " root=/dev/mmcblk0p2 rootdelay=1 ",
},
[3] = {
@@ -735,6 +738,7 @@ const struct board_api board_api_gta02 = {
.partition_index = 3,
.filesystem = FS_EXT2,
.filepath = "boot/uImage-GTA02.bin",
+ .initramfs_filepath = "boot/initrd-GTA02.bin",
.commandline_append = " root=/dev/mmcblk0p3 rootdelay=1 ",
},
[KERNEL_SOURCE_NAND_INDEX] = {
--
1.7.2.5
Timo Juhani Lindfors
2011-11-04 14:22:44 UTC
Permalink
This patch makes it possible to have a platform where the user can
optionally use an initramfs. Previously qi would abort if initramfs
was specified for the board but could not be found.

Adapted from patch sent by Michele Mazzucchi
<***@keencons.com> -- thanks!
---
src/phase2.c | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/phase2.c b/src/phase2.c
index 4a7ff18..2c88f33 100644
--- a/src/phase2.c
+++ b/src/phase2.c
@@ -52,6 +52,21 @@ static void indicate(enum ui_indication ui_indication)
(this_board->set_ui_indication)(ui_indication);
}

+static int file_exists(const char * filepath)
+{
+ switch (this_kernel->filesystem) {
+ case FS_EXT2:
+ if (!ext2fs_mount()) {
+ /* filesystem error, pretend file doesn't exist */
+ puts("Unable to mount ext2 filesystem\n");
+ return 0;
+ }
+ return (ext2fs_open(filepath) >= 0);
+ default:
+ return 0;
+ }
+}
+
static int read_file(const char * filepath, u8 * destination, int size)
{
int len = size;
@@ -211,7 +226,7 @@ static void do_params(unsigned initramfs_len,
params->u.mem.size = this_board->linux_mem_size;
params = tag_next(params);

- if (this_kernel->initramfs_filepath) {
+ if (this_kernel->initramfs_filepath && initramfs_len > 0) {
/* INITRD2 tag */
params->hdr.tag = ATAG_INITRD2;
params->hdr.size = tag_size(tag_initrd);
@@ -425,7 +440,7 @@ static void try_this_kernel(void)

/* initramfs if needed */

- if (this_kernel->initramfs_filepath) {
+ if (this_kernel->initramfs_filepath && file_exists(this_kernel->initramfs_filepath)) {
indicate(UI_IND_INITRAMFS_PULL);
initramfs_len = read_file(this_kernel->initramfs_filepath,
(u8 *)this_board->linux_mem_start + INITRD_OFFSET,
--
1.7.2.5
Timo Juhani Lindfors
2011-11-04 14:22:42 UTC
Permalink
This is mostly needed since Debian policy is probably in the future
going to require build logs that show what flags have been passed to
compiler and linker. If needed, we can add support for V=1 flag in the
future.
---
Makefile | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 5f4e779..c254b83 100644
--- a/Makefile
+++ b/Makefile
@@ -63,10 +63,10 @@ UDFU_IMAGE = $(IMAGE_DIR)/qi-$(CPU)-$(BUILD_VERSION).udfu
MKUDFU = $(TOOLS)/mkudfu

%.o: %.S
- @$(CC) $(CFLAGS) -o $@ $<
+ $(CC) $(CFLAGS) -o $@ $<

%.o: %.c
- @$(CC) $(CFLAGS) -o $@ $<
+ $(CC) $(CFLAGS) -o $@ $<

all:${UDFU_IMAGE}

@@ -77,11 +77,11 @@ ${MKUDFU}:

${UDFU_IMAGE}:${OBJS} ${MKUDFU}
mkdir -p image
- @$(LD) ${LDFLAGS} -T$(LDS) -g $(OBJS) -o ${TARGET} ${LIBS}
- @$(OBJCOPY) -O binary -S ${TARGET} ${IMAGE}
- @$(MKUDFU) -v ${UDFU_VID} -p ${UDFU_PID} -r ${UDFU_REV} \
+ $(LD) ${LDFLAGS} -T$(LDS) -g $(OBJS) -o ${TARGET} ${LIBS}
+ $(OBJCOPY) -O binary -S ${TARGET} ${IMAGE}
+ $(MKUDFU) -v ${UDFU_VID} -p ${UDFU_PID} -r ${UDFU_REV} \
-d ${IMAGE} ${UDFU_IMAGE}
- @$(OBJDUMP) -d ${TARGET} >${IMAGE}.dis
+ $(OBJDUMP) -d ${TARGET} >${IMAGE}.dis

clean:
@rm -f *~ src/*.o src/*~
--
1.7.2.5
Paul Fertser
2011-11-11 20:03:10 UTC
Permalink
Hi,
Post by Timo Juhani Lindfors
This patch makes it easier to modify kernel source list in the future,
it does not cause any functional changes.
This, and the other 4 patches pushed along with an alternative
to your 5/6 patch.

Big thanks!
--
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:***@gmail.com
Loading...