Skip to content

Commit 321a8ec

Browse files
author
Roberto Gordo Saez
committed
Initial commit - smartQi bootloader
0 parents  commit 321a8ec

29 files changed

+5616
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.*
2+
*.o
3+
*.a
4+
*.so
5+
!.gitignore
6+
7+
*.orig
8+
*.rej
9+
10+
image/*

Makefile

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# This program is free software; you can redistribute it and/or
2+
# modify it under the terms of the GNU General Public License as
3+
# published by the Free Software Foundation; either version 2 of
4+
# the License, or (at your option) any later version.
5+
#
6+
# This program is distributed in the hope that it will be useful,
7+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
8+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9+
# GNU General Public License for more details.
10+
#
11+
# You should have received a copy of the GNU General Public License
12+
# along with this program; if not, write to the Free Software
13+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
14+
# MA 02111-1307 USA
15+
#
16+
17+
include config.mk
18+
19+
BUILD_DATE := $(shell date -Iseconds)
20+
BUILD_HOST := $(shell hostname)
21+
BUILD_VERSION := 20091105-SmartQ
22+
23+
LDS = src/cpu/$(CPU)/qi.lds
24+
INCLUDE = include
25+
IMAGE_DIR = image
26+
TOOLS = tools
27+
CFLAGS = -Wall -Werror -I $(INCLUDE) -c -Os -fno-strict-aliasing -mlong-calls \
28+
-fno-common -ffixed-r8 -msoft-float -fno-builtin -ffreestanding \
29+
-march=armv6 -mno-thumb-interwork -Wstrict-prototypes -fno-stack-protector \
30+
-DBUILD_HOST="${BUILD_HOST}" -DBUILD_VERSION="${BUILD_VERSION}" \
31+
-DBUILD_DATE="${BUILD_DATE}" -DQI_CPU="${CPU}" -DSMARTQ
32+
LDFLAGS =
33+
34+
S_SRCS = $(wildcard src/cpu/$(CPU)/*.S)
35+
S_OBJS = $(patsubst %.S,%.o, $(S_SRCS))
36+
C_SRCS = $(wildcard src/*.c) \
37+
$(wildcard src/fs/*.c) \
38+
$(wildcard src/cpu/$(CPU)/*.c)
39+
C_OBJS = $(patsubst %.c,%.o, $(C_SRCS))
40+
41+
SRCS = ${S_SRCS} ${C_SRCS}
42+
OBJS = ${S_OBJS} ${C_OBJS}
43+
LIBS = -L${COMPILER_LIB_PATH} -lgcc
44+
45+
TARGET = $(IMAGE_DIR)/start_qi_all-$(CPU)
46+
IMAGE = $(IMAGE_DIR)/qi-$(CPU)-$(BUILD_VERSION)
47+
48+
%.o: %.S
49+
@$(CC) $(CFLAGS) -o $@ $<
50+
51+
%.o: %.c
52+
@$(CC) $(CFLAGS) -o $@ $<
53+
54+
all:${IMAGE}
55+
56+
${OBJS}:${SRCS} ${INCLUDE}/*.h
57+
58+
${IMAGE}:${OBJS}
59+
@mkdir -p $(IMAGE_DIR)
60+
@$(LD) ${LDFLAGS} -T$(LDS) -g $(OBJS) -o ${TARGET} ${LIBS}
61+
@$(OBJCOPY) -O binary -S ${TARGET} ${IMAGE}
62+
@$(OBJDUMP) -d ${TARGET} > ${IMAGE}.dis
63+
64+
clean:
65+
@rm -f *~ src/*.o src/*~
66+
@rm -f src/cpu/*/*.o src/cpu/*/*~
67+
@rm -f src/fs/*.o src/fs/*~
68+
@rm -f include/*~ ${IMAGE_DIR}/*

README

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
SmartQ Qi
2+
=========
3+
4+
This is a modified Qi bootloader for the SmartQ 5 MID. It can boot from the
5+
external SD card (keep the "move/fullscreen" button pressed and then press
6+
"power").
7+
8+
Use make to compile. The resulting binary file will be placed on
9+
image/qi-s3c6410-<version>-SmartQ. Look at the script install-smartq-qi.sh
10+
in order to make a bootable SD card.
11+
12+
-- Roberto Gordo Saez <[email protected]>
13+
14+
15+
Qi
16+
==
17+
18+
Qi (named by Alan Cox on Openmoko kernel list) is a minimal bootloader that
19+
"breathes life" into Linux. Its goal is to stay close to the minimum needed
20+
to "load" and then "boot" Linux -- no boot menus, additional peripheral init
21+
or private states.
22+
23+
24+
What's wrong with U-Boot, they keep telling people to not reinvent the wheel?
25+
=============================================================================
26+
27+
U-Boot is gradually becoming a simplified knockoff of Linux. After using it a
28+
while, it became clear we were cutting and pasting drivers into U-Boot from
29+
Linux, cutting them down and not having a plan to maintain the U-Boot versions
30+
as the Linux ones were changed.
31+
32+
We decided that we would use full Linux for things that Linux is good at and
33+
only have the bootloader do the device init that is absolutely required before
34+
Linux can be pulled into memory and started. In practice since we had a working
35+
U-Boot implementation it meant cutting that right down to the bone (start.S
36+
mainly for s3c2442) and then building it up from scratch optimized to just do
37+
load and boot.
38+
39+
40+
Samsung - specific boot sequence
41+
================================
42+
43+
Right now Qi supports Samsung "steppingstone" scheme devices, but in fact it's
44+
the same in processors like iMX31 that there is a small area of SRAM that is
45+
prepped with NAND content via ROM on the device. There's nothing that stops Qi
46+
use on processors without steppingstone, although the ATAG stuff assumes we deal
47+
with ARM based processor.
48+
49+
50+
Appending to commandline
51+
========================
52+
53+
You can append to the Qi commandline by creating a file /boot/append-<device>,
54+
eg, /boot/append-GTA02 containing the additional kernel commandline you want.
55+
56+
This means you can affect the boot per-rootfs, but that if you reimage the
57+
rootfs you at the same time define what is appeneded. Because these files are
58+
looked for with the <device> name in them, options can be selected depending on
59+
the device the rootfs is run on.
60+
61+
62+
Initrd support
63+
==============
64+
65+
Initrd or initramfs in separate file is supported to be loaded at given
66+
memory address in addition to kernel image. The ATAGs are issued accordingly.

config.mk

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
CPU=s3c6410
3+
4+
CROSS_PATH=/usr/local/software/toolchain-arm-karmic.rgs0
5+
CROSS_COMPILE=${CROSS_PATH}/bin/arm-none-linux-gnueabi-
6+
7+
COMPILER_LIB_PATH_PRE=${CROSS_PATH}/lib/gcc/arm-none-linux-gnueabi
8+
COMPILER_LIB_PATH=${COMPILER_LIB_PATH_PRE}/`ls ${COMPILER_LIB_PATH_PRE}`
9+
10+
AS = $(CROSS_COMPILE)as
11+
LD = $(CROSS_COMPILE)ld
12+
CC = $(CROSS_COMPILE)gcc
13+
OBJCOPY = $(CROSS_COMPILE)objcopy
14+
OBJDUMP = $(CROSS_COMPILE)objdump
15+
HOSTCC = gcc
16+
17+
export CROSS_COMPILE AD LD CC OBJCOPY OBJDUMP MKUDFU

include/ext2.h

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* GRUB -- GRand Unified Bootloader
3+
* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4+
*
5+
* (C) Copyright 2003 Sysgo Real-Time Solutions, AG <www.elinos.com>
6+
* Pavel Bartusek <[email protected]>
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21+
*/
22+
23+
/* An implementation for the Ext2FS filesystem ported from GRUB.
24+
* Some parts of this code (mainly the structures and defines) are
25+
* from the original ext2 fs code, as found in the linux kernel.
26+
*/
27+
28+
29+
#define SECTOR_SIZE 0x200
30+
#define SECTOR_BITS 9
31+
32+
/* Error codes */
33+
typedef enum
34+
{
35+
ERR_NONE = 0,
36+
ERR_BAD_FILENAME,
37+
ERR_BAD_FILETYPE,
38+
ERR_BAD_GZIP_DATA,
39+
ERR_BAD_GZIP_HEADER,
40+
ERR_BAD_PART_TABLE,
41+
ERR_BAD_VERSION,
42+
ERR_BELOW_1MB,
43+
ERR_BOOT_COMMAND,
44+
ERR_BOOT_FAILURE,
45+
ERR_BOOT_FEATURES,
46+
ERR_DEV_FORMAT,
47+
ERR_DEV_VALUES,
48+
ERR_EXEC_FORMAT,
49+
ERR_FILELENGTH,
50+
ERR_FILE_NOT_FOUND,
51+
ERR_FSYS_CORRUPT,
52+
ERR_FSYS_MOUNT,
53+
ERR_GEOM,
54+
ERR_NEED_LX_KERNEL,
55+
ERR_NEED_MB_KERNEL,
56+
ERR_NO_DISK,
57+
ERR_NO_PART,
58+
ERR_NUMBER_PARSING,
59+
ERR_OUTSIDE_PART,
60+
ERR_READ,
61+
ERR_SYMLINK_LOOP,
62+
ERR_UNRECOGNIZED,
63+
ERR_WONT_FIT,
64+
ERR_WRITE,
65+
ERR_BAD_ARGUMENT,
66+
ERR_UNALIGNED,
67+
ERR_PRIVILEGED,
68+
ERR_DEV_NEED_INIT,
69+
ERR_NO_DISK_SPACE,
70+
ERR_NUMBER_OVERFLOW,
71+
72+
MAX_ERR_NUM
73+
} ext2fs_error_t;
74+
75+
76+
extern int ext2fs_ls(char *dirname);
77+
extern int ext2fs_open(const char *filename);
78+
extern int ext2fs_read(char *buf, unsigned len);
79+
extern int ext2fs_mount(void);
80+
extern int ext2fs_close(void);

include/i2c-bitbang.h

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* (C) Copyright 2007 OpenMoko, Inc.
3+
* Author: Andy Green <[email protected]>
4+
* Modified for SmartQ, 2009, Roberto Gordo Saez <[email protected]>
5+
*
6+
* Generic i2c bitbang state machine
7+
*
8+
* This program is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU General Public License as
10+
* published by the Free Software Foundation; either version 2 of
11+
* the License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21+
* MA 02111-1307 USA
22+
*
23+
*/
24+
25+
/* controls symbol sequencing on i2c */
26+
27+
enum i2c_bitbang_control {
28+
IBCONTROL_DO_START = -1,
29+
IBCONTROL_DO_STOP = -2,
30+
IBCONTROL_DO_READ = -3,
31+
IBCONTROL_COMPLETE = -4
32+
};
33+
34+
/* control intra-bit and byte states */
35+
36+
enum i2c_bitbang_states {
37+
IBS_INIT,
38+
39+
IBS_START1,
40+
IBS_START2,
41+
42+
IBS_ADS_TX_S,
43+
IBS_ADS_TX_H,
44+
IBS_ADS_TX_L,
45+
IBS_ADS_TX_ACK_H,
46+
IBS_ADS_TX_ACK_L,
47+
48+
IBS_DATA_RX_S,
49+
IBS_DATA_RX_H,
50+
IBS_DATA_RX_L,
51+
52+
IBS_DATA_RX_ACK_H,
53+
IBS_DATA_RX_ACK_L,
54+
55+
IBS_STOP1,
56+
IBS_STOP2,
57+
IBS_STOP3,
58+
IBS_STOP4
59+
};
60+
61+
/* context for bitbang GPIO pins and transaction */
62+
63+
struct i2c_bitbang {
64+
65+
enum i2c_bitbang_states state;
66+
int count;
67+
unsigned int data[8]; /* read result found here */
68+
int index;
69+
int index_read;
70+
71+
char (*read_sda)(void);
72+
/* data = 0 = op low, 1 == inp */
73+
void (*set)(char clock, char data);
74+
/* delay > 1 half-bit time, used by i2c_complete_synchronously() */
75+
void (*spin)(void);
76+
void (*close)(void);
77+
};

0 commit comments

Comments
 (0)