안녕하세요.
오늘 스터디에 나온 질문 내용 정리
왜 qemu-s5pc210의 entry가 0x40010000 번지이가?
qemu 코드를 분석해본 봐, 'arm_load_kernel' funtion에서 다음과 같이
#define KERNEL_LOAD_ADDR 0x00010000 entry = info->loader_start + KERNEL_LOAD_ADDR; |
=>https://git.greensocs.com/qemu/qemu-sc/blob/f93eb9ff66868df42f8433d16f2dc48a4af2490f/hw/arm_boot.c
213번째 라인
entry로 설정하는 것을 발견했습니다.
info->loader_start 값은
https://lists.nongnu.org/archive/html/qemu-devel/2011-12/msg00845.html
위 url 가셔서 보시면
+#define S5PC210_DRAM0_BASE_ADDR 0x40000000
+ +#define S5PC210_BASE_BOOT_ADDR S5PC210_DRAM0_BASE_ADDR + +static struct arm_boot_info s5pc210_binfo = { + .loader_start = S5PC210_BASE_BOOT_ADDR, +};
위와 같은 patch를 확인 할 수 있습니다.
즉 entry = 0x40000000 + 0x00010000 이기 때문에 링크스크립트에 40010000으로 셋팅하는 듯합니다.
댓글 3
-
woos
2016.05.09 00:28
-
haru
2016.05.09 11:07
그렇다면, 실제 커널을 로드할 때 0x40000000 으로 설정을 해도 상관이 없다는 말씀이신건가요?
-
woos
2016.05.10 01:48
네. 근데 올리는 타입을 좀 달리해야 됩니다.
-kernel [KERNEL IMG] 옵션을 주면 이미지 파일을 이미 정의된 kernel 로드 주소로 로딩합니다.
이때 이 주소는 리눅스 kernel이 로딩 되는 주소고요.
임의의 주소로 로딩하고 싶으면 u-boot 이미지와 함께 uimage로 커널을 만들어서 올리면,
uimage 헤더를 u-boot가 읽어 원하는 주소로 로딩해서 수행할수 있습니다.
한 10년전에 커널 만들때 쓰던 옵션인데 참고해서 보시면 무슨 말을 하는지 이해가 되실겁니다.
================================================
run: compile $(TARGET) $(UTARGET) result
@dd of=build/image/flash.img bs=128k count=128 if=/dev/zero
@dd of=build/image/flash.img bs=128k conv=notrunc if=build/image/gumstix/u-boot-connex-400-r1604.bin
@dd of=build/image/flash.img bs=128k conv=notrunc seek=2 if=build/image/gumstix/gumstix-custom-connex.rootfs.jffs2
@dd of=build/image/flash.img bs=128k conv=notrunc seek=120 if=$(UTARGET)
gnome-terminal -x "qemu-system-arm -M connex -m 289 -nographic -monitor null -pflash build/image/flash.img"
sh.imgdebug: compile $(TARGET) $(UTARGET) result
@dd of=build/image/flash.img bs=128k count=128 if=/dev/zero
@dd of=build/image/flash.img bs=128k conv=notrunc if=build/image/gumstix/u-boot-connex-400-r1604.bin
@dd of=build/image/flash.img bs=128k conv=notrunc seek=2 if=build/image/gumstix/gumstix-custom-connex.rootfs.jffs2
@dd of=build/image/flash.img bs=128k conv=notrunc seek=120 if=$(UTARGET)
qemu-system-arm -M connex -m 289 -s -S -serial console -serial pty -monitor null -pflash build/image/flash.img &
$(DDD) --debugger arm-linux-gdb &$(ELF_TARGET): $(addsuffix /built-in.o,$(SUBDIRS))
$(LD) $(LDFLAGS) $(LDSCRIPT) -N $^ -o $@
$(NM) $(ELF_TARGET) | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > Symbols.map
$(TARGET): $(ELF_TARGET)
$(OBJCOPY) $(OFLAGS) $^ $@
$(UTARGET): $(TARGET)
build/tools/uboot-1.3.4/tools/mkimage -A arm -O linux -T kernel -C none -a 0xA0000000 -e 0xA0000000 -n 'NOUS' -d $^ $@
.
ㅎㅎㅎ 그닥 대단한 이유는 없습니다.
리눅스 커널이 그 위치에 로딩되기에 -kernel 옵션을 주면 qemu에서 지원해주는 사항입니다.
그다지 큰 의미가 있는건 아닙니다.