공유 폴더에 PPT 복사하기
putty 설정에 대한 설명
우분투에서 명령을 실행한다
$ mkdir pi_bsp ; cd pi_bsp // 안만들어지면 오류뜬다
또는
$ mkdir pi_bsp && cd pi_bsp // 안만들어지면 실행안된다
$ sudo apt-get install gawk git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat cpio python-setuptools python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev xterm rsync curl zstd lz4 bison flex
> 실행해서 다시 변경된 내용만 설치 준비한다
$ sudo apt install crossbuild-essential-armhf
> arm 32bit 툴체인 설치
p78
$ which arm-linux-gnueabihf-gcc
명령어를 실행하면 위 파일이 어딨는지 알려준다
$ ls | wc -l
개수를 알려주고
wc 명령어의 옵션을 보고싶으면
$ wc --help
입력하면
$ ls arm-linux-gnueabihf-*
$ ls arm-linux-gnueabihf-* | wc -l
~$ cat /etc/passwd
~$ sudo cat /etc/shadow
패스워드를 초기화는 가능하지만 알 수 없다
이렇게 암호화 되어있다
$ cd -
이전 디렉토리로 이동
$ cd
홈 디렉토리로 이동
$ cd ~
홈 디렉토리로 이동
pi@pi11~$ dmesg
파이에서 커널 메시지 로그를 불러온다
~/pi_bsp$ git clone git://git.denx.de/u-boot.git
u-boot 다운로드
$ cd u-boot
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- rpi_4_32b_defconfig
u-boot/configs에 rpi_4_32b_defconfig가 들어있다
크로스컴파일을 위해 arm용으로 make한다
rpi_4_32b_defconfig 대신 menuconfig를 하면 .config를 수정할 수 있다
$ sudo apt install libncurses-dev
그 전에 이 명령어로 설치를 해줘야 한다
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all
설치하면
오류가 나는데 라이브러리가 없어서 그렇다
$ sudo apt-get update
$ sudo apt-get install libssl-dev
두개 설치하고 다시 make하면
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- all
막~ 다운받으면서 끝난다
$ ls -lt
시간 순서로 보여준다
$ file u-boot.bin
파일 정보를 알려준다
ubuntu
$ cp u-boot.bin /srv/nfs/
pi
$ cd /mnt/ubuntu_nfs/
$ ls
NFS(네트워크 파일 시스템)로 보냈다
$ sudo cp u-boot.bin /boot/.
그 후 복사해서 이동시킨다
config.txt 맨 마지막줄에
kernel=u-boot.bin
추가한다
만약 심볼릭 링크가 설정 안돼있으면
config.txt 파일을 rm 명령어로 삭제하고
$ ln -s firmware/config.txt config.txt
명령어로 수정한다
$ cd firmware
$ sudo mv ../u-boot.bin .
$ sudo reboot
하면
여기까지 된다
reset을 통해 재부팅하면
autoload가 안된다 한다
U-Boot>setenv bootargs 8250.nr_uarts=1 console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait rw
U-Boot> printenv bootcmd //bootcmd 확인
bootcmd=run distro_bootcmd
- user_mmc_boot U-boot 부팅 스프립트 작성
U-Boot> setenv bootcmd 'run user_mmc_boot'
U-Boot> setenv user_mmc_boot 'mmc dev 0; fatload mmc 0:1 ${kernel_addr_r} kernel7l.img; fatload mmc 0:1 ${fdt_addr_r} bcm2711-rpi-4-b.dtb; bootz ${kernel_addr_r} - ${fdt_addr_r} '
U-Boot> saveenv //환경변수 저장
U-Boot> reset //재부팅
켜지는 중 4초가 지나기 전 엔터를 눌러서 부트로드 수정을 할 수 있다
부트로더는 어셈블리어로 되어있고 고급 C언어기 때문에 어렵다
U-Boot : 확장성이 용이
부트로더 동작
메모리 구조
$ md.l 0xfe200000 4
$ md.l 0xfe200000 8
0x7e200000.
MMU를 거친 주소(p806~7)
그러면 위의 그림에서 4가 추가된 것이 보인다
6번핀(1번째 LED)만 on 하기 위해
U-Boot> mw.l 0xfe200000 0x00040000
U-Boot> mw.l 0xfe20001c 0x00000040
U-Boot> mw.l 0xfe200028 0x00000040
위의 코드로 LED를 끈다
UART에 숫자를 안쓰게되면 통신이 끊긴다
U-Boot> mw.l 0xfe200000 0x09240000 // gpio6~9 output
U-Boot> mw.l 0xfe200004 0x00012249 // gpio10~13 output
U-Boot> mw.l 0xfe20001c 0x00003fc0 // gpio6~13 LED on
U-Boot> mw.l 0xfe200028 0x00003fc0 // gpio6~9 LED off
output을 설정할 때는 위의 그림의 숫자 아래에 적힌대로 000 001 ... 처럼 설정 후 4비트씩 읽어 계산한다
즉, select는 3비트씩 설정된다
Set시에는 Set주소를 기억하고 해당 GPIO에 맞는 비트를 1로 바꾼다