├── rp_jtagenable ├── kernel8.img ├── rp_jtagenable_32.S ├── rp_jtagenable_64.S ├── config_32bit.txt ├── config_64bit.txt ├── kernel.img ├── kernel7.img ├── kernel7l.img ├── kernel_oldrp1.img ├── memmap ├── cfg │ ├── bcm2835.cfg │ ├── bcm2711_64.cfg │ ├── bcm2836_64.cfg │ ├── bcm2837_64.cfg │ ├── bcm2711.cfg │ ├── bcm2836.cfg │ └── bcm2837.cfg ├── rp_jtagenable_32_oldrp1.S ├── rp_jtagenable_64_.S ├── README.md └── Makefile ├── rp_pcm_dma_rec ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp01 ├── memmap_rp23 ├── README.md ├── Makefile └── rp_pcm_dma_rec.c ├── rp_pcm ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp23 ├── memmap_rp01 ├── README.md └── Makefile ├── rp_pcm_dma ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp01 ├── memmap_rp23 ├── README.md └── Makefile ├── rp_uart ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp23 ├── memmap_rp01 ├── README.md ├── Makefile └── rp_uart.c ├── rp_blink_gpio4 ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp01 ├── memmap_rp23 ├── README.md ├── rp_blink_gpio4.c └── Makefile ├── rp_clockgen ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp23 ├── memmap_rp01 ├── README.md ├── Makefile └── rp_clockgen.c ├── rp_cyclecounter ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp01 ├── memmap_rp23 ├── README.md ├── Makefile └── rp_cyclecounter.c ├── rp_framebuffer ├── config_rp01.txt ├── config_rp23.txt ├── config_rp234.txt ├── memmap_rp01 ├── memmap_rp23 ├── README.md └── Makefile ├── rp_i2c_ar1010 ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp23 ├── memmap_rp01 ├── README.md └── Makefile ├── rp_midi_out ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp23 ├── memmap_rp01 ├── README.md ├── Makefile └── rp_midi_out.c ├── rp_pwm_audio ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp23 ├── memmap_rp01 ├── README.md ├── Makefile └── rp_pwm_audio.c ├── rp_spi0_psxpad ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp01 ├── memmap_rp23 ├── README.md └── Makefile ├── rp_framebuffer_dma1 ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp01 ├── memmap_rp23 ├── README.md ├── Makefile └── rp_framebuffer_dma1.c ├── rp_framebuffer_dma8 ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp01 ├── memmap_rp23 ├── README.md └── Makefile ├── rp_pwm_audio_dma ├── config_rp01.txt ├── config_rp23.txt ├── memmap_rp23 ├── memmap_rp01 ├── README.md ├── Makefile └── rp_pwm_audio_dma.c ├── rp_exclusive ├── config.txt ├── memmap ├── README.md ├── Makefile └── rp_exclusive.c ├── .gitignore ├── LICENSE └── README.md /rp_jtagenable/kernel8.img: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /rp_jtagenable/rp_jtagenable_32.S: -------------------------------------------------------------------------------- 1 | l: b l 2 | -------------------------------------------------------------------------------- /rp_jtagenable/rp_jtagenable_64.S: -------------------------------------------------------------------------------- 1 | l: b l 2 | -------------------------------------------------------------------------------- /rp_jtagenable/config_32bit.txt: -------------------------------------------------------------------------------- 1 | arm_64bit=0 2 | enable_jtag_gpio=1 3 | -------------------------------------------------------------------------------- /rp_jtagenable/config_64bit.txt: -------------------------------------------------------------------------------- 1 | arm_64bit=1 2 | enable_jtag_gpio=1 3 | -------------------------------------------------------------------------------- /rp_pcm_dma_rec/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | 4 | -------------------------------------------------------------------------------- /rp_jtagenable/kernel.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AZO234/RaspberryPi_BareMetal/HEAD/rp_jtagenable/kernel.img -------------------------------------------------------------------------------- /rp_jtagenable/kernel7.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AZO234/RaspberryPi_BareMetal/HEAD/rp_jtagenable/kernel7.img -------------------------------------------------------------------------------- /rp_jtagenable/kernel7l.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AZO234/RaspberryPi_BareMetal/HEAD/rp_jtagenable/kernel7l.img -------------------------------------------------------------------------------- /rp_jtagenable/kernel_oldrp1.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AZO234/RaspberryPi_BareMetal/HEAD/rp_jtagenable/kernel_oldrp1.img -------------------------------------------------------------------------------- /rp_pcm/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_pcm_dma/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_uart/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_blink_gpio4/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_clockgen/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_cyclecounter/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_framebuffer/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_i2c_ar1010/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_midi_out/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_pcm_dma_rec/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | 6 | -------------------------------------------------------------------------------- /rp_pwm_audio/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_spi0_psxpad/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_framebuffer_dma1/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_framebuffer_dma8/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_pwm_audio_dma/config_rp01.txt: -------------------------------------------------------------------------------- 1 | disable_overscan=1 2 | framebuffer_swap=0 3 | hdmi_drive=2 4 | hdmi_group=2 5 | hdmi_mode=82 6 | 7 | -------------------------------------------------------------------------------- /rp_exclusive/config.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_pcm/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_uart/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_clockgen/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_jtagenable/memmap: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x1000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | } 11 | 12 | -------------------------------------------------------------------------------- /rp_midi_out/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_pcm_dma/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_pwm_audio/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_blink_gpio4/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_cyclecounter/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_framebuffer/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_framebuffer/config_rp234.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_i2c_ar1010/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_pwm_audio_dma/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_spi0_psxpad/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_framebuffer_dma1/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_framebuffer_dma8/config_rp23.txt: -------------------------------------------------------------------------------- 1 | kernel_old=1 2 | disable_commandline_tags=1 3 | disable_overscan=1 4 | framebuffer_swap=0 5 | hdmi_drive=2 6 | hdmi_group=2 7 | hdmi_mode=82 8 | 9 | -------------------------------------------------------------------------------- /rp_exclusive/memmap: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_pcm/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_uart/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_clockgen/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_i2c_ar1010/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_midi_out/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_pcm/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_pcm_dma/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_pcm_dma/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_pwm_audio/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_uart/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_blink_gpio4/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_blink_gpio4/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_clockgen/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_cyclecounter/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_cyclecounter/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_framebuffer/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_framebuffer/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_i2c_ar1010/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_midi_out/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_pcm_dma_rec/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x10000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_pcm_dma_rec/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x10000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_pwm_audio/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_pwm_audio_dma/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_spi0_psxpad/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_spi0_psxpad/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_framebuffer_dma1/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_framebuffer_dma1/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_framebuffer_dma8/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_framebuffer_dma8/memmap_rp23: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x0, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /rp_pwm_audio_dma/memmap_rp01: -------------------------------------------------------------------------------- 1 | 2 | MEMORY 3 | { 4 | ram : ORIGIN = 0x8000, LENGTH = 0x8000000 5 | } 6 | 7 | SECTIONS 8 | { 9 | .text : { *(.text*) } > ram 10 | .bss : { *(.bss*) } > ram 11 | } 12 | 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | *.su 34 | -------------------------------------------------------------------------------- /rp_jtagenable/cfg/bcm2835.cfg: -------------------------------------------------------------------------------- 1 | # BCM2835 2 | 3 | if { [info exists CHIPNAME] } { 4 | set _CHIPNAME $CHIPNAME 5 | } else { 6 | set _CHIPNAME bcm2835 7 | } 8 | 9 | if { [info exists CPU_TAPID] } { 10 | set _CPU_TAPID $CPU_TAPID 11 | } else { 12 | set _CPU_TAPID 0x07b7617F 13 | } 14 | 15 | reset_config trst_only 16 | jtag_ntrst_delay 400 17 | 18 | jtag newtap $_CHIPNAME arm -irlen 5 -expected-id $_CPU_TAPID 19 | 20 | target create $_CHIPNAME.arm arm11 -chain-position $_CHIPNAME.arm 21 | $_CHIPNAME.arm configure -event gdb-attach { halt } 22 | -------------------------------------------------------------------------------- /rp_blink_gpio4/README.md: -------------------------------------------------------------------------------- 1 | blink with GPIO4 sample 2 | ======================= 3 | 4 | This is blink LED with GPIO4 sample code. 5 | 6 | If you can run this program, 7 | blink LED. 8 | 9 | ----- 10 | 11 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 12 | 13 | How to make: 14 | 1. install "arm-none-eabi-gcc". 15 | 2. Open "Makefile " with texteditor, and change options. 16 | BOARD=RPZERO/RP1/RP2/RP3 17 | 3. make 18 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 19 | 20 | How to run: 21 | Put follow files to FAT SD card. 22 | * "bootcode.bin" 23 | * "start.elf" 24 | * "config.txt" <- config_rp01.txt or config_rp23.txt 25 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 26 | 27 | Firmware: 28 | Grub "bootcode.bin" and "start.elf" at 29 | https://github.com/raspberrypi/firmware/tree/master/boot 30 | 31 | Reference 32 | --------- 33 | - dwelch67/raspberrypi: Raspberry Pi ARM based bare metal examples https://github.com/dwelch67/raspberrypi 34 | 35 | -------------------------------------------------------------------------------- /rp_exclusive/README.md: -------------------------------------------------------------------------------- 1 | CPU core exclusive sample 2 | ========================= 3 | 4 | This is CPU core exclusive sample code. 5 | 6 | This sample use UART 115200/8/N/1. 7 | Connect follow pins to PC. 8 | * pin 6 GND 9 | * Pin 8 TXD(GPIO14/ALT5) 10 | * Pin10 RXD(GPIO15/ALT5) 11 | 12 | If you can run this program, 13 | output to terminal, CPU core number of got lock. 14 | 15 | ----- 16 | 17 | For Raspberry Pi 2/3 Bare Metal code by AZO. 18 | 19 | How to make: 20 | 1. install "arm-none-eabi-gcc". 21 | 2. Open "Makefile " with texteditor, and change options. 22 | BOARD=RP2/RP3 23 | 3. make 24 | 4. If successfully, output "kernel7.img". 25 | 26 | How to run: 27 | Put follow files to FAT SD card. 28 | * "bootcode.bin" 29 | * "start.elf" 30 | * "config.txt" 31 | * "kernel7.img" 32 | 33 | Firmware: 34 | Grub "bootcode.bin" and "start.elf" at 35 | https://github.com/raspberrypi/firmware/tree/master/boot 36 | 37 | Reference 38 | --------- 39 | - dwelch67/raspberrypi: Raspberry Pi ARM based bare metal examples https://github.com/dwelch67/raspberrypi 40 | 41 | -------------------------------------------------------------------------------- /rp_cyclecounter/README.md: -------------------------------------------------------------------------------- 1 | ARM Cycle Counter sample 2 | ======================== 3 | 4 | This is ARM Cycle Counter sample code. 5 | 6 | This sample use UART 115200/8/N/1. 7 | Connect follow pins to PC. 8 | * pin 6 GND 9 | * Pin 8 TXD(GPIO14/ALT5) 10 | * Pin10 RXD(GPIO15/ALT5) 11 | 12 | If you can run this program, 13 | output CPU clock count per 1us(=MHz). 14 | 15 | ----- 16 | 17 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 18 | 19 | How to make: 20 | 1. install "arm-none-eabi-gcc". 21 | 2. Open "Makefile " with texteditor, and change options. 22 | BOARD=RPZERO/RP1/RP2/RP3 23 | 3. make 24 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 25 | 26 | How to run: 27 | Put follow files to FAT SD card. 28 | * "bootcode.bin" 29 | * "start.elf" 30 | * "config.txt" <- config_rp01.txt or config_rp23.txt 31 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 32 | 33 | Firmware: 34 | Grub "bootcode.bin" and "start.elf" at 35 | https://github.com/raspberrypi/firmware/tree/master/boot 36 | 37 | Reference 38 | --------- 39 | - ARM TRM 40 | 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 AZO 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /rp_jtagenable/cfg/bcm2711_64.cfg: -------------------------------------------------------------------------------- 1 | # BCM2711(64bit) 2 | 3 | if { [info exists CHIPNAME] } { 4 | set _CHIPNAME $CHIPNAME 5 | } else { 6 | set _CHIPNAME bcm2711 7 | } 8 | 9 | if { [info exists CPU_TAPID] } { 10 | set _CPU_TAPID $CPU_TAPID 11 | } else { 12 | set _CPU_TAPID 0x4ba00477 13 | } 14 | 15 | reset_config trst_only 16 | jtag_ntrst_delay 400 17 | 18 | jtag newtap $_CHIPNAME tap -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPU_TAPID -enable 19 | dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.tap 20 | 21 | set CTIBASE {0x80420000 0x80520000 0x80620000 0x80720000} 22 | set DBGBASE {0x80410000 0x80510000 0x80610000 0x80710000} 23 | 24 | set _cores 4 25 | 26 | for {set _core 0} {$_core < $_cores} {incr _core} { 27 | cti create $_CHIPNAME.cti.$_core -dap $_CHIPNAME.dap -ap-num 0 -ctibase [lindex $CTIBASE $_core] 28 | target create $_CHIPNAME.$_core aarch64 -dap $_CHIPNAME.dap -coreid $_core -dbgbase [lindex $DBGBASE $_core] -cti $_CHIPNAME.cti.$_core 29 | $_CHIPNAME.$_core configure -event reset-assert-post "aarch64 dbginit" 30 | } 31 | 32 | target smp $_CHIPNAME.0 $_CHIPNAME.1 $_CHIPNAME.2 $_CHIPNAME.3 33 | 34 | -------------------------------------------------------------------------------- /rp_jtagenable/cfg/bcm2836_64.cfg: -------------------------------------------------------------------------------- 1 | # BCM2836(64bit) 2 | 3 | if { [info exists CHIPNAME] } { 4 | set _CHIPNAME $CHIPNAME 5 | } else { 6 | set _CHIPNAME bcm2836 7 | } 8 | 9 | if { [info exists CPU_TAPID] } { 10 | set _CPU_TAPID $CPU_TAPID 11 | } else { 12 | set _CPU_TAPID 0x4ba00477 13 | } 14 | 15 | reset_config trst_only 16 | jtag_ntrst_delay 400 17 | 18 | jtag newtap $_CHIPNAME tap -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPU_TAPID -enable 19 | dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.tap 20 | 21 | set CTIBASE {0x80018000 0x8001A000 0x8001C000 0x8001E000} 22 | set DBGBASE {0x80010000 0x80012000 0x80014000 0x80016000} 23 | 24 | set _cores 4 25 | 26 | for {set _core 0} {$_core < $_cores} {incr _core} { 27 | cti create $_CHIPNAME.cti.$_core -dap $_CHIPNAME.dap -ap-num 0 -ctibase [lindex $CTIBASE $_core] 28 | target create $_CHIPNAME.$_core aarch64 -dap $_CHIPNAME.dap -coreid $_core -dbgbase [lindex $DBGBASE $_core] -cti $_CHIPNAME.cti.$_core 29 | $_CHIPNAME.$_core configure -event reset-assert-post "aarch64 dbginit" 30 | } 31 | 32 | target smp $_CHIPNAME.0 $_CHIPNAME.1 $_CHIPNAME.2 $_CHIPNAME.3 33 | 34 | -------------------------------------------------------------------------------- /rp_jtagenable/cfg/bcm2837_64.cfg: -------------------------------------------------------------------------------- 1 | # BCM2837(64bit) 2 | 3 | if { [info exists CHIPNAME] } { 4 | set _CHIPNAME $CHIPNAME 5 | } else { 6 | set _CHIPNAME bcm2837 7 | } 8 | 9 | if { [info exists CPU_TAPID] } { 10 | set _CPU_TAPID $CPU_TAPID 11 | } else { 12 | set _CPU_TAPID 0x4ba00477 13 | } 14 | 15 | reset_config trst_only 16 | jtag_ntrst_delay 400 17 | 18 | jtag newtap $_CHIPNAME tap -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPU_TAPID -enable 19 | dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.tap 20 | 21 | set CTIBASE {0x80018000 0x8001A000 0x8001C000 0x8001E000} 22 | set DBGBASE {0x80010000 0x80012000 0x80014000 0x80016000} 23 | 24 | set _cores 4 25 | 26 | for {set _core 0} {$_core < $_cores} {incr _core} { 27 | cti create $_CHIPNAME.cti.$_core -dap $_CHIPNAME.dap -ap-num 0 -ctibase [lindex $CTIBASE $_core] 28 | target create $_CHIPNAME.$_core aarch64 -dap $_CHIPNAME.dap -coreid $_core -dbgbase [lindex $DBGBASE $_core] -cti $_CHIPNAME.cti.$_core 29 | $_CHIPNAME.$_core configure -event reset-assert-post "aarch64 dbginit" 30 | } 31 | 32 | target smp $_CHIPNAME.0 $_CHIPNAME.1 $_CHIPNAME.2 $_CHIPNAME.3 33 | 34 | -------------------------------------------------------------------------------- /rp_uart/README.md: -------------------------------------------------------------------------------- 1 | UART sample 2 | =========== 3 | 4 | This is Auxiliary UART(UART1) sample code. 5 | (UART0 is used Bluetooth in RP3) 6 | 7 | This sample use UART 115200/8/N/1. 8 | Connect follow pins to PC. 9 | * pin 6 GND 10 | * Pin 8 TXD(GPIO14/ALT5) 11 | * Pin10 RXD(GPIO15/ALT5) 12 | 13 | If you can run this program, 14 | Host PC key input will callback. 15 | 16 | ----- 17 | 18 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 19 | 20 | How to make: 21 | 1. install "arm-none-eabi-gcc". 22 | 2. Open "Makefile " with texteditor, and change options. 23 | BOARD=RPZERO/RP1/RP2/RP3 24 | 3. make 25 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 26 | 27 | How to run: 28 | Put follow files to FAT SD card. 29 | * "bootcode.bin" 30 | * "start.elf" 31 | * "config.txt" <- config_rp01.txt or config_rp23.txt 32 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 33 | 34 | Firmware: 35 | Grub "bootcode.bin" and "start.elf" at 36 | https://github.com/raspberrypi/firmware/tree/master/boot 37 | 38 | Reference 39 | --------- 40 | - dwelch67/raspberrypi: Raspberry Pi ARM based bare metal examples https://github.com/dwelch67/raspberrypi 41 | 42 | -------------------------------------------------------------------------------- /rp_clockgen/README.md: -------------------------------------------------------------------------------- 1 | Clock generator sample 2 | ====================== 3 | 4 | Clock generator sample code. 5 | 6 | Connect follow pins to external devices. 7 | * pin 7 GPCLK0(GPIO4/ALT0) 8 | * pin31 GPCLK2(GPIO6/ALT0) 9 | 10 | If you can run this program, 11 | RPi can supply clock to external device. 12 | 13 | Don't use GPCLK1 (it's probably used for the Ethernet clock). 14 | 15 | ----- 16 | 17 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 18 | 19 | How to make: 20 | 1. install "arm-none-eabi-gcc". 21 | 2. Open "Makefile " with texteditor, and change options. 22 | BOARD=RPZERO/RP1/RP2/RP3 23 | 3. make 24 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 25 | 26 | How to run: 27 | Put follow files to FAT SD card. 28 | * "bootcode.bin" 29 | * "start.elf" 30 | * "config.txt" <- config_rp01.txt or config_rp23.txt 31 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 32 | 33 | Firmware: 34 | Grub "bootcode.bin" and "start.elf" at 35 | https://github.com/raspberrypi/firmware/tree/master/boot 36 | 37 | Reference 38 | --------- 39 | - Peripheral specification 40 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf 41 | 42 | -------------------------------------------------------------------------------- /rp_pwm_audio/README.md: -------------------------------------------------------------------------------- 1 | PWM audio sample 2 | ================ 3 | 4 | This is PWM audio sample code. 5 | 6 | Plug phone jack 3.5. 7 | 8 | If use Raspberry Pi Zero, connect forrow pins to phone. 9 | - pin30 - GND 10 | - pin32 - PWM0(GPIO12/ALT0) 11 | - pin33 - PWM1(GPIO13/ALT0) 12 | 13 | If you can run this program, 14 | you'll hear 1kHz(48kHz/13bit/stereo) sin-curve sound. 15 | More than 14bit, sound is strangely. 16 | 17 | ----- 18 | 19 | For Raspberry Pi 1/2/3 Bare Metal code by AZO. 20 | 21 | How to make: 22 | 1. install "arm-none-eabi-gcc". 23 | 2. Open "Makefile " with texteditor, and change options. 24 | BOARD=RP1/RP2/RP3 25 | 3. make 26 | 4. If successfully, output "kernel.img"(RP1) or "kernel7.img"(RP2/3). 27 | 28 | How to run: 29 | Put follow files to FAT SD card. 30 | * "bootcode.bin" 31 | * "start.elf" 32 | * "config.txt" <- config_rp1.txt or config_rp23.txt 33 | * "kernel.img"(RP1) or "kernel7.img"(RP2/3) 34 | 35 | Firmware: 36 | Grub "bootcode.bin" and "start.elf" at 37 | https://github.com/raspberrypi/firmware/tree/master/boot 38 | 39 | Reference 40 | --------- 41 | - PeterLemon/RaspberryPi: Raspberry Pi Bare Metal Assembly Programming 42 | https://github.com/PeterLemon/RaspberryPi 43 | 44 | -------------------------------------------------------------------------------- /rp_framebuffer/README.md: -------------------------------------------------------------------------------- 1 | Frame Buffer sample 2 | =================== 3 | 4 | *** temporary(2020/09/10) *** 5 | Now tuning to new compiler and rpi4! 6 | This code work on RPi1/3 only. 7 | 8 | This is Frame Buffer sample code. 9 | 10 | Connect HDMI to 1080p/24bit color display. 11 | 12 | If you can run this program, 13 | you'll see color pattern. 14 | (This pattern is Japanese broadcast standard ARIB STD-B28.) 15 | 16 | ----- 17 | 18 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 19 | 20 | How to make: 21 | 1. install "arm-none-eabi-gcc". 22 | 2. Open "Makefile " with texteditor, and change options. 23 | BOARD=RPZERO/RP1/RP2/RP3 24 | 3. make 25 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 26 | 27 | How to run: 28 | Put follow files to FAT SD card. 29 | * "bootcode.bin" 30 | * "start.elf" 31 | * "config.txt" <- config_rp01.txt or config_rp23.txt 32 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 33 | 34 | Firmware: 35 | Grub "bootcode.bin" and "start.elf" at 36 | https://github.com/raspberrypi/firmware/tree/master/boot 37 | 38 | Reference 39 | --------- 40 | - PeterLemon/RaspberryPi: Raspberry Pi Bare Metal Assembly Programming https://github.com/PeterLemon/RaspberryPi 41 | 42 | -------------------------------------------------------------------------------- /rp_pwm_audio_dma/README.md: -------------------------------------------------------------------------------- 1 | PWM audio + DMA sample 2 | ====================== 3 | 4 | This is PWM audio sample code. 5 | 6 | Plug phone jack 3.5. 7 | 8 | If use Raspberry Pi Zero, connect forrow pins to phone. 9 | - pin30 - GND 10 | - pin32 - PWM0(GPIO12/ALT0) 11 | - pin33 - PWM1(GPIO13/ALT0) 12 | 13 | If you can run this program, 14 | you'll hear 1kHz(48kHz/13bit/stereo) sin-curve sound. 15 | More than 14bit, sound is strangely. 16 | 17 | ----- 18 | 19 | For Raspberry Pi 1/2/3 Bare Metal code by AZO. 20 | 21 | How to make: 22 | 1. install "arm-none-eabi-gcc". 23 | 2. Open "Makefile " with texteditor, and change options. 24 | BOARD=RP1/RP2/RP3 25 | 3. make 26 | 4. If successfully, output "kernel.img"(RP1) or "kernel7.img"(RP2/3). 27 | 28 | How to run: 29 | Put follow files to FAT SD card. 30 | * "bootcode.bin" 31 | * "start.elf" 32 | * "config.txt" <- config_rp01.txt or config_rp23.txt 33 | * "kernel.img"(RP1) or "kernel7.img"(RP2/3) 34 | 35 | Firmware: 36 | Grub "bootcode.bin" and "start.elf" at 37 | https://github.com/raspberrypi/firmware/tree/master/boot 38 | 39 | Reference 40 | --------- 41 | - PeterLemon/RaspberryPi: Raspberry Pi Bare Metal Assembly Programming 42 | https://github.com/PeterLemon/RaspberryPi 43 | 44 | -------------------------------------------------------------------------------- /rp_midi_out/README.md: -------------------------------------------------------------------------------- 1 | MIDI OUT sample 2 | =============== 3 | 4 | This is MIDI OUT sample code. 5 | 6 | This sample use UART 31250/8/N/1. 7 | Connect follow pins and registances to MIDI sound generator's MIDI IN. 8 | * pin 2 5V - 220 owm registance - DIN 5P 4 pin 9 | * pin 6 GND - DIN 5P 2 pin 10 | * Pin 8 TXD(GPIO14/ALT5) - 220 owm registance - DIN 5P 5 pin 11 | 12 | If you can run this program, 13 | You can hear loop of C major melody 'C D E F G A B C'. 14 | 15 | ----- 16 | 17 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 18 | 19 | How to make: 20 | 1. install "arm-none-eabi-gcc". 21 | 2. Open "Makefile " with texteditor, and change options. 22 | BOARD=RPZERO/RP1/RP2/RP3 23 | 3. make 24 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 25 | 26 | How to run: 27 | Put follow files to FAT SD card. 28 | * "bootcode.bin" 29 | * "start.elf" 30 | * "config.txt" <- config_rp01.txt or config_rp23.txt 31 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 32 | 33 | Firmware: 34 | Grub "bootcode.bin" and "start.elf" at 35 | https://github.com/raspberrypi/firmware/tree/master/boot 36 | 37 | Reference 38 | --------- 39 | - PIC AVR 工作室 UARTとMIDIの変換器 http://picavr.uunyan.com/avr_m_uart_midi.html 40 | 41 | -------------------------------------------------------------------------------- /rp_jtagenable/cfg/bcm2711.cfg: -------------------------------------------------------------------------------- 1 | # BCM2711 2 | 3 | if { [info exists CHIPNAME] } { 4 | set _CHIPNAME $CHIPNAME 5 | } else { 6 | set _CHIPNAME bcm2711 7 | } 8 | 9 | if { [info exists CPU_TAPID] } { 10 | set _CPU_TAPID $CPU_TAPID 11 | } else { 12 | set _CPU_TAPID 0x4ba00477 13 | } 14 | 15 | reset_config trst_only 16 | jtag_ntrst_delay 400 17 | 18 | jtag newtap $_CHIPNAME tap -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPU_TAPID -enable 19 | dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.tap 20 | 21 | target create $_CHIPNAME.cpu.0 cortex_a -dap $_CHIPNAME.dap -coreid 0 -dbgbase 0x80410000 22 | target create $_CHIPNAME.cpu.1 cortex_a -dap $_CHIPNAME.dap -coreid 1 -dbgbase 0x80510000 23 | target create $_CHIPNAME.cpu.2 cortex_a -dap $_CHIPNAME.dap -coreid 2 -dbgbase 0x80610000 24 | target create $_CHIPNAME.cpu.3 cortex_a -dap $_CHIPNAME.dap -coreid 3 -dbgbase 0x80710000 25 | 26 | target smp $_CHIPNAME.cpu.0 $_CHIPNAME.cpu.1 $_CHIPNAME.cpu.2 $_CHIPNAME.cpu.3 27 | 28 | $_CHIPNAME.cpu.0 configure -event reset-assert-post "cortex_a dbginit" 29 | $_CHIPNAME.cpu.1 configure -event reset-assert-post "cortex_a dbginit" 30 | $_CHIPNAME.cpu.2 configure -event reset-assert-post "cortex_a dbginit" 31 | $_CHIPNAME.cpu.3 configure -event reset-assert-post "cortex_a dbginit" 32 | 33 | -------------------------------------------------------------------------------- /rp_jtagenable/cfg/bcm2836.cfg: -------------------------------------------------------------------------------- 1 | # BCM2836 2 | 3 | if { [info exists CHIPNAME] } { 4 | set _CHIPNAME $CHIPNAME 5 | } else { 6 | set _CHIPNAME bcm2836 7 | } 8 | 9 | if { [info exists CPU_TAPID] } { 10 | set _CPU_TAPID $CPU_TAPID 11 | } else { 12 | set _CPU_TAPID 0x4ba00477 13 | } 14 | 15 | reset_config trst_only 16 | jtag_ntrst_delay 400 17 | 18 | jtag newtap $_CHIPNAME tap -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPU_TAPID -enable 19 | dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.tap 20 | 21 | target create $_CHIPNAME.cpu.0 cortex_a -dap $_CHIPNAME.dap -coreid 0 -dbgbase 0x80010000 22 | target create $_CHIPNAME.cpu.1 cortex_a -dap $_CHIPNAME.dap -coreid 1 -dbgbase 0x80012000 23 | target create $_CHIPNAME.cpu.2 cortex_a -dap $_CHIPNAME.dap -coreid 2 -dbgbase 0x80014000 24 | target create $_CHIPNAME.cpu.3 cortex_a -dap $_CHIPNAME.dap -coreid 3 -dbgbase 0x80016000 25 | 26 | target smp $_CHIPNAME.cpu.0 $_CHIPNAME.cpu.1 $_CHIPNAME.cpu.2 $_CHIPNAME.cpu.3 27 | 28 | $_CHIPNAME.cpu.0 configure -event reset-assert-post "cortex_a dbginit" 29 | $_CHIPNAME.cpu.1 configure -event reset-assert-post "cortex_a dbginit" 30 | $_CHIPNAME.cpu.2 configure -event reset-assert-post "cortex_a dbginit" 31 | $_CHIPNAME.cpu.3 configure -event reset-assert-post "cortex_a dbginit" 32 | 33 | -------------------------------------------------------------------------------- /rp_jtagenable/cfg/bcm2837.cfg: -------------------------------------------------------------------------------- 1 | # BCM2837 2 | 3 | if { [info exists CHIPNAME] } { 4 | set _CHIPNAME $CHIPNAME 5 | } else { 6 | set _CHIPNAME bcm2837 7 | } 8 | 9 | if { [info exists CPU_TAPID] } { 10 | set _CPU_TAPID $CPU_TAPID 11 | } else { 12 | set _CPU_TAPID 0x4ba00477 13 | } 14 | 15 | reset_config trst_only 16 | jtag_ntrst_delay 400 17 | 18 | jtag newtap $_CHIPNAME tap -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPU_TAPID -enable 19 | dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.tap 20 | 21 | target create $_CHIPNAME.cpu.0 cortex_a -dap $_CHIPNAME.dap -coreid 0 -dbgbase 0x80010000 22 | target create $_CHIPNAME.cpu.1 cortex_a -dap $_CHIPNAME.dap -coreid 1 -dbgbase 0x80012000 23 | target create $_CHIPNAME.cpu.2 cortex_a -dap $_CHIPNAME.dap -coreid 2 -dbgbase 0x80014000 24 | target create $_CHIPNAME.cpu.3 cortex_a -dap $_CHIPNAME.dap -coreid 3 -dbgbase 0x80016000 25 | 26 | target smp $_CHIPNAME.cpu.0 $_CHIPNAME.cpu.1 $_CHIPNAME.cpu.2 $_CHIPNAME.cpu.3 27 | 28 | $_CHIPNAME.cpu.0 configure -event reset-assert-post "cortex_a dbginit" 29 | $_CHIPNAME.cpu.1 configure -event reset-assert-post "cortex_a dbginit" 30 | $_CHIPNAME.cpu.2 configure -event reset-assert-post "cortex_a dbginit" 31 | $_CHIPNAME.cpu.3 configure -event reset-assert-post "cortex_a dbginit" 32 | 33 | -------------------------------------------------------------------------------- /rp_framebuffer_dma1/README.md: -------------------------------------------------------------------------------- 1 | Frame Buffer + DMA sample 2 | ========================= 3 | 4 | This is Frame Buffer + DMA sample code. 5 | 6 | Connect HDMI to 1080p color display. 7 | 8 | This sample use UART 115200/8/N/1. 9 | Connect follow pins to PC. 10 | * pin 6 GND 11 | * Pin 8 TXD(GPIO14/ALT5) 12 | * Pin10 RXD(GPIO15/ALT5) 13 | 14 | If you can run this program, 15 | you'll see moving color pattern. 16 | (This pattern is Japanese broadcast standard ARIB STD-B28.) 17 | And output frame count per 1s to UART. 18 | 19 | ----- 20 | 21 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 22 | 23 | How to make: 24 | 1. install "arm-none-eabi-gcc". 25 | 2. Open "Makefile " with texteditor, and change options. 26 | BOARD=RPZERO/RP1/RP2/RP3 27 | 3. make 28 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 29 | 30 | How to run: 31 | Put follow files to FAT SD card. 32 | * "bootcode.bin" 33 | * "start.elf" 34 | * "config.txt" <- config_rp01.txt or config_rp23.txt 35 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 36 | 37 | Firmware: 38 | Grub "bootcode.bin" and "start.elf" at 39 | https://github.com/raspberrypi/firmware/tree/master/boot 40 | 41 | Reference 42 | --------- 43 | - PeterLemon/RaspberryPi: Raspberry Pi Bare Metal Assembly Programming https://github.com/PeterLemon/RaspberryPi 44 | 45 | -------------------------------------------------------------------------------- /rp_framebuffer_dma8/README.md: -------------------------------------------------------------------------------- 1 | Frame Buffer + DMAx8 sample 2 | =========================== 3 | 4 | This is Frame Buffer + DMAx8 sample code. 5 | 6 | Connect HDMI to 1080p color display. 7 | 8 | This sample use UART 115200/8/N/1. 9 | Connect follow pins to PC. 10 | * pin 6 GND 11 | * Pin 8 TXD(GPIO14/ALT5) 12 | * Pin10 RXD(GPIO15/ALT5) 13 | 14 | If you can run this program, 15 | you'll see moving color pattern, over 60fps. 16 | (This pattern is Japanese broadcast standard ARIB STD-B28.) 17 | And output frame count per 1s to UART. 18 | 19 | ----- 20 | 21 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 22 | 23 | How to make: 24 | 1. install "arm-none-eabi-gcc". 25 | 2. Open "Makefile " with texteditor, and change options. 26 | BOARD=RPZERO/RP1/RP2/RP3 27 | 3. make 28 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 29 | 30 | How to run: 31 | Put follow files to FAT SD card. 32 | * "bootcode.bin" 33 | * "start.elf" 34 | * "config.txt" <- config_rp01.txt or config_rp23.txt 35 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 36 | 37 | Firmware: 38 | Grub "bootcode.bin" and "start.elf" at 39 | https://github.com/raspberrypi/firmware/tree/master/boot 40 | 41 | Reference 42 | --------- 43 | - PeterLemon/RaspberryPi: Raspberry Pi Bare Metal Assembly Programming https://github.com/PeterLemon/RaspberryPi 44 | 45 | -------------------------------------------------------------------------------- /rp_pcm_dma/README.md: -------------------------------------------------------------------------------- 1 | PCM(I2S) + DMA sample 2 | ===================== 3 | 4 | This is PCM/I2S with DMA sample code. 5 | (You connot hear 3.5 phone jack.) 6 | You need any external I2S DAC board. 7 | 8 | Connect I2S DAC board to below pins. 9 | * pin 7 - GPCLK0 (GPIO04/ALT0), MCLK/SCLK 10 | * pin12 - PCM_CLK (GPIO18/ALT0), BCK/BCLK/BITCLK 11 | * pin35 - PCM_FR (GPIO19/ALT0), LRCK 12 | * pin40 - PCM_DOUT (GPIO21/ALT0), Data 13 | You can use VCC and GND. 14 | 15 | If you can run this program, 16 | you'll hear 1kHz(48kHz/16bit/stereo) sin-curve sound. 17 | 18 | This sample can play 384kHz/32bit/stereo sound. 19 | I used Pimoroni's "pHAT DAC". 20 | https://shop.pimoroni.com/products/phat-dac 21 | 22 | 768kHz/32bit/stereo was failed. 23 | 24 | ----- 25 | 26 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 27 | 28 | How to make: 29 | 1. install "arm-none-eabi-gcc". 30 | 2. Open "Makefile " with texteditor, and change options. 31 | BOARD=RPZERO/RP1/RP2/RP3 32 | 3. make 33 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 34 | 35 | How to run: 36 | Put follow files to FAT SD card. 37 | * "bootcode.bin" 38 | * "start.elf" 39 | * "config.txt" <- config_rp01.txt or config_rp23.txt 40 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 41 | 42 | Firmware: 43 | Grub "bootcode.bin" and "start.elf" at 44 | https://github.com/raspberrypi/firmware/tree/master/boot 45 | 46 | Reference 47 | --------- 48 | - I²S - Wikipedia https://en.wikipedia.org/wiki/I%C2%B2S 49 | - 04 « 4月 « 2008 « PCオーディオブログ http://blog.ratocsystems.com/wp/2008/04/04/19/ 50 | 51 | 52 | -------------------------------------------------------------------------------- /rp_pcm/README.md: -------------------------------------------------------------------------------- 1 | PCM(I2S) sample 2 | =============== 3 | 4 | This is PCM/I2S sample code. 5 | (You connot hear 3.5 phone jack.) 6 | You need any external I2S DAC board. 7 | 8 | Connect I2S DAC board to below pins. 9 | * pin 7 - GPCLK0 (GPIO04/ALT0), MCLK/SCLK 10 | * pin12 - PCM_CLK (GPIO18/ALT0), BCK/BCLK/BITCLK 11 | * pin35 - PCM_FR (GPIO19/ALT0), LRCK 12 | * pin40 - PCM_DOUT (GPIO21/ALT0), Data 13 | You can use VCC and GND. 14 | 15 | If you can run this program, 16 | you'll hear 1kHz(48kHz/16bit/stereo) sin-curve sound. 17 | 18 | This sample can play until 92kHz/32bit/stereo sound. 19 | More than 192kHz, sound noisy. Probably CPU and memory need more speed. 20 | I used Pimoroni's "pHAT DAC". 21 | https://shop.pimoroni.com/products/phat-dac 22 | 23 | ----- 24 | 25 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 26 | 27 | How to make: 28 | 1. install "arm-none-eabi-gcc". 29 | 2. Open "Makefile " with texteditor, and change options. 30 | BOARD=RPZERO/RP1/RP2/RP3 31 | 3. make 32 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 33 | 34 | How to run: 35 | Put follow files to FAT SD card. 36 | * "bootcode.bin" 37 | * "start.elf" 38 | * "config.txt" <- config_rp01.txt or config_rp23.txt 39 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 40 | 41 | Firmware: 42 | Grub "bootcode.bin" and "start.elf" at 43 | https://github.com/raspberrypi/firmware/tree/master/boot 44 | 45 | Reference 46 | --------- 47 | - I²S - Wikipedia https://en.wikipedia.org/wiki/I%C2%B2S 48 | - 04 « 4月 « 2008 « PCオーディオブログ http://blog.ratocsystems.com/wp/2008/04/04/19/ 49 | 50 | 51 | -------------------------------------------------------------------------------- /rp_pcm_dma_rec/README.md: -------------------------------------------------------------------------------- 1 | PCM(I2S) record sample 2 | ====================== 3 | 4 | This is PCM/I2S record sample code. 5 | You need any external I2S DAC board or Raspberry Pi. 6 | 7 | Connect I2S DAC board to below pins. 8 | * pin12 - PCM_CLK (GPIO18/ALT0), BCK/BCLK/BITCLK 9 | * pin35 - PCM_FR (GPIO19/ALT0), LRCK 10 | * pin38 - PCM_DIN (GPIO20/ALT0), Data 11 | You can use VCC and GND. 12 | 13 | This sample use UART 115200/8/N/1. 14 | Connect follow pins to PC. 15 | * pin 6 GND 16 | * Pin 8 TXD(GPIO14/ALT5) 17 | * Pin10 RXD(GPIO15/ALT5) 18 | 19 | If you can run this program, 20 | First ready prompt to record to terminal. 21 | You push space key, start recording. 22 | Recording is done, then, prompt to playback to terminal. 23 | You push space key, start playback to PWM speaker. 24 | 25 | This sample can recode 768kHz/32bit/stereo sound. 26 | 27 | ----- 28 | 29 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 30 | 31 | How to make: 32 | 1. install "arm-none-eabi-gcc". 33 | 2. Open "Makefile " with texteditor, and change options. 34 | BOARD=RPZERO/RP1/RP2/RP3 35 | 3. make 36 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 37 | 38 | How to run: 39 | Put follow files to FAT SD card. 40 | * "bootcode.bin" 41 | * "start.elf" 42 | * "config.txt" <- config_rp01.txt or config_rp23.txt 43 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 44 | 45 | Firmware: 46 | Grub "bootcode.bin" and "start.elf" at 47 | https://github.com/raspberrypi/firmware/tree/master/boot 48 | 49 | Reference 50 | --------- 51 | - I²S - Wikipedia https://en.wikipedia.org/wiki/I%C2%B2S 52 | - 04 « 4月 « 2008 « PCオーディオブログ http://blog.ratocsystems.com/wp/2008/04/04/19/ 53 | 54 | 55 | -------------------------------------------------------------------------------- /rp_i2c_ar1010/README.md: -------------------------------------------------------------------------------- 1 | TFM-1010(AN1010) FM radio I2C sample 2 | ==================================== 3 | 4 | This is TFM-1010(AN1010) FM radio I2C sample code. 5 | 6 | Connect follow pins to TFM-1010. 7 | * pin 1 3.3V - pin 6 VCC 8 | * pin 3 SDA1(GPIO2/ALT0) - pin 10 Data 9 | * pin 5 SCL1(GPIO3/ALT0) - pin 9 Data 10 | * pin 9 GND - pin 5 GND & pin 8 BUSMODE 11 | 12 | Connect TFM-1010 follow pins. 13 | * pin 1 ANT - long long cable 14 | * pin 3 L-Out - phone 15 | * pin 4 R-Out - phone 16 | * pin 5 GND - phone 17 | 18 | This sample use UART 115200/8/N/1. 19 | Connect follow pins to PC. 20 | * pin 6 GND 21 | * Pin 8 TXD(GPIO14/ALT5) 22 | * Pin10 RXD(GPIO15/ALT5) 23 | 24 | If you can run this program, 25 | Display menu to terminal. 26 | 1. Hit '1' to send array values. 27 | 2. Hit '5' to begin seek. 28 | If tune successful, you can hear radio program. 29 | 30 | ----- 31 | 32 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 33 | 34 | How to make: 35 | 1. install "arm-none-eabi-gcc". 36 | 2. Open "Makefile " with texteditor, and change options. 37 | BOARD=RPZERO/RP1/RP2/RP3 38 | 3. make 39 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 40 | 41 | How to run: 42 | Put follow files to FAT SD card. 43 | * "bootcode.bin" 44 | * "start.elf" 45 | * "config.txt" <- config_rp01.txt or config_rp23.txt 46 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 47 | 48 | Firmware: 49 | Grub "bootcode.bin" and "start.elf" at 50 | https://github.com/raspberrypi/firmware/tree/master/boot 51 | 52 | Reference 53 | --------- 54 | - dwelch67/raspberrypi: Raspberry Pi ARM based bare metal examples https://github.com/dwelch67/raspberrypi 55 | - SPK-TFM-1010 SPECIFICATION.pdf https://strawberry-linux.com/pub/SPK-TFM-1010%20SPECIFICATION.pdf 56 | - https://strawberry-linux.com/pub/AR1000ATMega168v11.zip 57 | 58 | -------------------------------------------------------------------------------- /rp_jtagenable/rp_jtagenable_32_oldrp1.S: -------------------------------------------------------------------------------- 1 | .text 2 | .globl _start 3 | _start: 4 | ldr r3, =bcm283x_per 5 | ldr r3, [r3] 6 | ldr r2, =0x200000 /* GPFSEL0 */ 7 | add r2, r2, r3 8 | ldr r0, [r2] 9 | mov r1, #7 /* FSEL4 */ 10 | lsl r1, r1, #12 11 | mvn r1, r1 12 | and r0, r0, r1 13 | mov r1, #2 /* ALT5 */ 14 | lsl r1, r1, #12 15 | orr r0, r0, r1 16 | str r0, [r2] 17 | ldr r2, =0x200008 /* GPFSEL2 */ 18 | add r2, r2, r3 19 | ldr r0, [r2] 20 | mov r1, #7 /* FSEL22 */ 21 | lsl r1, r1, #6 22 | mvn r1, r1 23 | and r0, r0, r1 24 | mov r1, #3 /* ALT4 */ 25 | lsl r1, r1, #6 26 | orr r0, r0, r1 27 | mov r1, #7 /* FSEL23 */ 28 | lsl r1, r1, #9 29 | mvn r1, r1 30 | and r0, r0, r1 31 | mov r1, #3 /* ALT4 */ 32 | lsl r1, r1, #9 33 | orr r0, r0, r1 34 | mov r1, #7 /* FSEL24 */ 35 | lsl r1, r1, #12 36 | mvn r1, r1 37 | and r0, r0, r1 38 | mov r1, #3 /* ALT4 */ 39 | lsl r1, r1, #12 40 | orr r0, r0, r1 41 | mov r1, #7 /* FSEL25 */ 42 | lsl r1, r1, #15 43 | mvn r1, r1 44 | and r0, r0, r1 45 | mov r1, #3 /* ALT4 */ 46 | lsl r1, r1, #15 47 | orr r0, r0, r1 48 | mov r1, #7 /* FSEL27 */ 49 | lsl r1, r1, #21 50 | mvn r1, r1 51 | and r0, r0, r1 52 | mov r1, #3 /* ALT4 */ 53 | lsl r1, r1, #21 54 | orr r0, r0, r1 55 | str r0, [r2] 56 | 57 | /* disable pullUD */ 58 | ldr r2, =0x200094 /* GPPUD */ 59 | add r2, r2, r3 60 | mov r0, #0 61 | str r0, [r2] 62 | mov r1, #150 /* 150 cycle wait */ 63 | _start_disable_pullud_1: 64 | mov r0, r0 65 | subs r1, r1, #1 66 | bne _start_disable_pullud_1 67 | ldr r2, =0x200098 /* GPPUDCLK0 */ 68 | add r2, r2, r3 69 | ldr r0, [r2] 70 | orr r0, r0, #0xFC00000 /* GPIO22-27 */ 71 | str r0, [r2] 72 | mov r1, #150 /* 150 cycle wait */ 73 | _start_disable_pullud_2: 74 | mov r0, r0 75 | subs r1, r1, #1 76 | bne _start_disable_pullud_2 77 | mov r0, #0 78 | str r0, [r2] 79 | 80 | loop: b loop 81 | 82 | bcm283x_per: .long 0x20000000 83 | 84 | -------------------------------------------------------------------------------- /rp_jtagenable/rp_jtagenable_64_.S: -------------------------------------------------------------------------------- 1 | .text 2 | .globl _start 3 | _start: 4 | mrs x0, S3_3_c0_c0_5 /* core0 only */ 5 | ands x0, x0, #0x3 6 | bne loop 7 | 8 | mov x3, #0 9 | ldr w3, =bcm283x_per 10 | ldr w3, [x3] 11 | ldr x2, =0x200008 /* GPFSEL2 */ 12 | add w2, w2, w3 13 | ldr w0, [x2] 14 | mov w1, #7 /* FSEL22 */ 15 | lsl w1, w1, #6 16 | mvn w1, w1 17 | and w0, w0, w1 18 | mov w1, #3 /* ALT4 */ 19 | lsl w1, w1, #6 20 | orr w0, w0, w1 21 | mov w1, #7 /* FSEL23 */ 22 | lsl w1, w1, #9 23 | mvn w1, w1 24 | and w0, w0, w1 25 | mov w1, #3 /* ALT4 */ 26 | lsl w1, w1, #9 27 | orr w0, w0, w1 28 | mov w1, #7 /* FSEL24 */ 29 | lsl w1, w1, #12 30 | mvn w1, w1 31 | and w0, w0, w1 32 | mov w1, #3 /* ALT4 */ 33 | lsl w1, w1, #12 34 | orr w0, w0, w1 35 | mov w1, #7 /* FSEL25 */ 36 | lsl w1, w1, #15 37 | mvn w1, w1 38 | and w0, w0, w1 39 | mov w1, #3 /* ALT4 */ 40 | lsl w1, w1, #15 41 | orr w0, w0, w1 42 | mov w1, #7 /* FSEL26 */ 43 | lsl w1, w1, #18 44 | mvn w1, w1 45 | and w0, w0, w1 46 | mov w1, #3 /* ALT4 */ 47 | lsl w1, w1, #18 48 | orr w0, w0, w1 49 | mov w1, #7 /* FSEL27 */ 50 | lsl w1, w1, #21 51 | mvn w1, w1 52 | and w0, w0, w1 53 | mov w1, #3 /* ALT4 */ 54 | lsl w1, w1, #21 55 | orr w0, w0, w1 56 | str w0, [x2] 57 | 58 | /* disable pullUD */ 59 | ldr x2, =0x200094 /* GPPUD */ 60 | add w2, w2, w3 61 | mov w0, #0 62 | str w0, [x2] 63 | mov w1, #150 /* 150 cycle wait */ 64 | _start_disable_pullud_1: 65 | mov w0, w0 66 | subs w1, w1, #1 67 | bne _start_disable_pullud_1 68 | ldr x2, =0x200098 /* GPPUDCLK0 */ 69 | add w2, w2, w3 70 | ldr w0, [x2] 71 | orr w0, w0, #0xFC00000 /* GPIO22-27 */ 72 | str w0, [x2] 73 | mov w1, #150 /* 150 cycle wait */ 74 | _start_disable_pullud_2: 75 | mov w0, w0 76 | subs w1, w1, #1 77 | bne _start_disable_pullud_2 78 | mov w0, #0 79 | str w0, [x2] 80 | 81 | loop: b loop 82 | 83 | bcm283x_per: .long 0x3F000000 84 | 85 | -------------------------------------------------------------------------------- /rp_spi0_psxpad/README.md: -------------------------------------------------------------------------------- 1 | PSX(Play Station 1/2) pad for SPI0 sample 2 | ========================================= 3 | 4 | This is PSX(Play Station 1/2) pad for SPI0 sample code. 5 | 6 | PSX controler pins (not PSX's socket, pad side) 7 | 123 456 789 8 | (...|...|...) 9 | 10 | Connect follow pad pins to RPi. 11 | * Pin1 DAT -> Pin19 MOSI(GPIO10/ALT0) 12 | * Pin2 CMD -> Pin21 MOSI(GPIO 9/ALT0) 13 | * Pin3 9V (for motor, If you not necessary NC) 14 | * Pin4 GND -> Pin 9 GND 15 | * Pin5 3.3V -> Pin 1 3.3V 16 | * Pin6 Attention -> Pin24 CE0_N(GPIO 8/ALT0) 17 | * Pin7 SCK -> Pin23 SCLK(GPIO11/ALT0) 18 | * Pin8 N.C. 19 | * Pin9 ACK -> N.C. 20 | 21 | This sample use UART 115200/8/N/1. 22 | Connect follow pins to PC. 23 | * Pin 6 GND 24 | * Pin 8 TXD(GPIO14/ALT5) 25 | * Pin10 RXD(GPIO15/ALT5) 26 | 27 | If you can run this program, 28 | display pressed pad buttons. 29 | 30 | To Do 31 | ---- 32 | - Get analog value button pressure 33 | - Pool with DMA 34 | 35 | ----- 36 | 37 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO. 38 | 39 | How to make: 40 | 1. install "arm-none-eabi-gcc". 41 | 2. Open "Makefile " with texteditor, and change options. 42 | BOARD=RPZERO/RP1/RP2/RP3 43 | 3. make 44 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 45 | 46 | How to run: 47 | Put follow files to FAT SD card. 48 | * "bootcode.bin" 49 | * "start.elf" 50 | * "config.txt" <- config_rp01.txt or config_rp23.txt 51 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 52 | 53 | Firmware: 54 | Grub "bootcode.bin" and "start.elf" at 55 | https://github.com/raspberrypi/firmware/tree/master/boot 56 | 57 | Reference 58 | --------- 59 | - dwelch67/raspberrypi: Raspberry Pi ARM based bare metal examples 60 | https://github.com/dwelch67/raspberrypi 61 | - Interfacing a PS2 (PlayStation 2) Controller - CuriousInventor Tutorials 62 | http://store.curiousinventor.com/guides/PS2/ 63 | -------------------------------------------------------------------------------- /rp_exclusive/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RP2 12 | AZO_BOARD = RP3 13 | ifeq ($(AZO_BOARD),RP2) 14 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 15 | else ifeq ($(AZO_BOARD),RP3) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 17 | endif 18 | 19 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 20 | AZO_CPU_SINGLE = 1 21 | ifeq ($(AZO_CPU_SINGLE),1) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 23 | endif 24 | endif 25 | 26 | COPS := -O0 -g3 $(COMMONOPS) 27 | #COPS = -O3 $(COMMONOPS) 28 | ASMOPS := -g3 $(COMMONOPS) 29 | 30 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 31 | gcc : rp_exclusive.hex kernel.img rp_exclusive.hex rp_exclusive.syms rp_exclusive.srec 32 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 33 | gcc : rp_exclusive.hex kernel7.img rp_exclusive.hex rp_exclusive.syms rp_exclusive.srec 34 | endif 35 | 36 | all : gcc 37 | 38 | clean : 39 | rm -f *.o 40 | rm -f *.bin 41 | rm -f *.hex 42 | rm -f *.elf 43 | rm -f *.list 44 | rm -f *.img 45 | rm -f *.bc 46 | rm -f *.syms 47 | rm -f *.srec 48 | rm -f *.clang.opt.s 49 | 50 | vectors.o : vectors.S 51 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 52 | 53 | rp_exclusive.o : rp_exclusive.c 54 | $(ARMGNU)-gcc $(COPS) -c rp_exclusive.c -o rp_exclusive.o 55 | 56 | rp_exclusive.elf : memmap vectors.o rp_exclusive.o 57 | $(ARMGNU)-ld vectors.o rp_exclusive.o -T memmap -o rp_exclusive.elf 58 | $(ARMGNU)-objdump -D rp_exclusive.elf > rp_exclusive.list 59 | 60 | kernel7.img : rp_exclusive.elf 61 | $(ARMGNU)-objcopy rp_exclusive.elf -O binary kernel7.img 62 | 63 | rp_exclusive.hex : rp_exclusive.elf 64 | $(ARMGNU)-objcopy rp_exclusive.elf -O ihex rp_exclusive.hex 65 | 66 | rp_exclusive.syms : rp_exclusive.elf 67 | $(ARMGNU)-nm -n rp_exclusive.elf > rp_exclusive.syms 68 | 69 | rp_exclusive.srec : rp_exclusive.elf 70 | $(ARMGNU)-objcopy rp_exclusive.elf -O srec rp_exclusive.srec 71 | 72 | -------------------------------------------------------------------------------- /rp_pcm/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_pcm.hex kernel.img rp_pcm.hex rp_pcm.syms rp_pcm.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_pcm.hex kernel7.img rp_pcm.hex rp_pcm.syms rp_pcm.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_pcm.o : rp_pcm.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_pcm.c -o rp_pcm.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_pcm.elf : memmap_rp01 vectors.o rp_pcm.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_pcm.elf : memmap_rp23 vectors.o rp_pcm.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_pcm.o -T memmap_rp01 -o rp_pcm.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_pcm.o -T memmap_rp23 -o rp_pcm.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_pcm.elf > rp_pcm.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_pcm.elf 76 | $(ARMGNU)-objcopy rp_pcm.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_pcm.elf 79 | $(ARMGNU)-objcopy rp_pcm.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_pcm.hex : rp_pcm.elf 83 | $(ARMGNU)-objcopy rp_pcm.elf -O ihex rp_pcm.hex 84 | 85 | rp_pcm.syms : rp_pcm.elf 86 | $(ARMGNU)-nm -n rp_pcm.elf > rp_pcm.syms 87 | 88 | rp_pcm.srec : rp_pcm.elf 89 | $(ARMGNU)-objcopy rp_pcm.elf -O srec rp_pcm.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_uart/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_uart.hex kernel.img rp_uart.hex rp_uart.syms rp_uart.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_uart.hex kernel7.img rp_uart.hex rp_uart.syms rp_uart.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_uart.o : rp_uart.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_uart.c -o rp_uart.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_uart.elf : memmap_rp01 vectors.o rp_uart.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_uart.elf : memmap_rp23 vectors.o rp_uart.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_uart.o -T memmap_rp01 -o rp_uart.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_uart.o -T memmap_rp23 -o rp_uart.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_uart.elf > rp_uart.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_uart.elf 76 | $(ARMGNU)-objcopy rp_uart.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_uart.elf 79 | $(ARMGNU)-objcopy rp_uart.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_uart.hex : rp_uart.elf 83 | $(ARMGNU)-objcopy rp_uart.elf -O ihex rp_uart.hex 84 | 85 | rp_uart.syms : rp_uart.elf 86 | $(ARMGNU)-nm -n rp_uart.elf > rp_uart.syms 87 | 88 | rp_uart.srec : rp_uart.elf 89 | $(ARMGNU)-objcopy rp_uart.elf -O srec rp_uart.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_pwm_audio/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),RP1) 37 | gcc : rp_pwm_audio.hex kernel.img rp_pwm_audio.hex rp_pwm_audio.syms rp_pwm_audio.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_pwm_audio.hex kernel7.img rp_pwm_audio.hex rp_pwm_audio.syms rp_pwm_audio.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_pwm_audio.o : rp_pwm_audio.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_pwm_audio.c -o rp_pwm_audio.o 61 | 62 | ifeq ($(AZO_BOARD),RP1) 63 | rp_pwm_audio.elf : memmap_rp01 vectors.o rp_pwm_audio.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_pwm_audio.elf : memmap_rp23 vectors.o rp_pwm_audio.o 66 | endif 67 | ifeq ($(AZO_BOARD),RP1) 68 | $(ARMGNU)-ld vectors.o rp_pwm_audio.o -T memmap_rp01 -o rp_pwm_audio.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_pwm_audio.o -T memmap_rp23 -o rp_pwm_audio.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_pwm_audio.elf > rp_pwm_audio.list 73 | 74 | ifeq ($(AZO_BOARD),RP1) 75 | kernel.img : rp_pwm_audio.elf 76 | $(ARMGNU)-objcopy rp_pwm_audio.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_pwm_audio.elf 79 | $(ARMGNU)-objcopy rp_pwm_audio.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_pwm_audio.hex : rp_pwm_audio.elf 83 | $(ARMGNU)-objcopy rp_pwm_audio.elf -O ihex rp_pwm_audio.hex 84 | 85 | rp_pwm_audio.syms : rp_pwm_audio.elf 86 | $(ARMGNU)-nm -n rp_pwm_audio.elf > rp_pwm_audio.syms 87 | 88 | rp_pwm_audio.srec : rp_pwm_audio.elf 89 | $(ARMGNU)-objcopy rp_pwm_audio.elf -O srec rp_pwm_audio.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_pcm_dma/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_pcm_dma.hex kernel.img rp_pcm_dma.hex rp_pcm_dma.syms rp_pcm_dma.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_pcm_dma.hex kernel7.img rp_pcm_dma.hex rp_pcm_dma.syms rp_pcm_dma.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_pcm_dma.o : rp_pcm_dma.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_pcm_dma.c -o rp_pcm_dma.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_pcm_dma.elf : memmap_rp01 vectors.o rp_pcm_dma.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_pcm_dma.elf : memmap_rp23 vectors.o rp_pcm_dma.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_pcm_dma.o -T memmap_rp01 -o rp_pcm_dma.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_pcm_dma.o -T memmap_rp23 -o rp_pcm_dma.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_pcm_dma.elf > rp_pcm_dma.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_pcm_dma.elf 76 | $(ARMGNU)-objcopy rp_pcm_dma.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_pcm_dma.elf 79 | $(ARMGNU)-objcopy rp_pcm_dma.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_pcm_dma.hex : rp_pcm_dma.elf 83 | $(ARMGNU)-objcopy rp_pcm_dma.elf -O ihex rp_pcm_dma.hex 84 | 85 | rp_pcm_dma.syms : rp_pcm_dma.elf 86 | $(ARMGNU)-nm -n rp_pcm_dma.elf > rp_pcm_dma.syms 87 | 88 | rp_pcm_dma.srec : rp_pcm_dma.elf 89 | $(ARMGNU)-objcopy rp_pcm_dma.elf -O srec rp_pcm_dma.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_clockgen/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_clockgen.hex kernel.img rp_clockgen.hex rp_clockgen.syms rp_clockgen.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_clockgen.hex kernel7.img rp_clockgen.hex rp_clockgen.syms rp_clockgen.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_clockgen.o : rp_clockgen.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_clockgen.c -o rp_clockgen.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_clockgen.elf : memmap_rp01 vectors.o rp_clockgen.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_clockgen.elf : memmap_rp23 vectors.o rp_clockgen.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_clockgen.o -T memmap_rp01 -o rp_clockgen.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_clockgen.o -T memmap_rp23 -o rp_clockgen.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_clockgen.elf > rp_clockgen.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_clockgen.elf 76 | $(ARMGNU)-objcopy rp_clockgen.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_clockgen.elf 79 | $(ARMGNU)-objcopy rp_clockgen.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_clockgen.hex : rp_clockgen.elf 83 | $(ARMGNU)-objcopy rp_clockgen.elf -O ihex rp_clockgen.hex 84 | 85 | rp_clockgen.syms : rp_clockgen.elf 86 | $(ARMGNU)-nm -n rp_clockgen.elf > rp_clockgen.syms 87 | 88 | rp_clockgen.srec : rp_clockgen.elf 89 | $(ARMGNU)-objcopy rp_clockgen.elf -O srec rp_clockgen.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_midi_out/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_midi_out.hex kernel.img rp_midi_out.hex rp_midi_out.syms rp_midi_out.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_midi_out.hex kernel7.img rp_midi_out.hex rp_midi_out.syms rp_midi_out.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_midi_out.o : rp_midi_out.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_midi_out.c -o rp_midi_out.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_midi_out.elf : memmap_rp01 vectors.o rp_midi_out.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_midi_out.elf : memmap_rp23 vectors.o rp_midi_out.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_midi_out.o -T memmap_rp01 -o rp_midi_out.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_midi_out.o -T memmap_rp23 -o rp_midi_out.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_midi_out.elf > rp_midi_out.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_midi_out.elf 76 | $(ARMGNU)-objcopy rp_midi_out.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_midi_out.elf 79 | $(ARMGNU)-objcopy rp_midi_out.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_midi_out.hex : rp_midi_out.elf 83 | $(ARMGNU)-objcopy rp_midi_out.elf -O ihex rp_midi_out.hex 84 | 85 | rp_midi_out.syms : rp_midi_out.elf 86 | $(ARMGNU)-nm -n rp_midi_out.elf > rp_midi_out.syms 87 | 88 | rp_midi_out.srec : rp_midi_out.elf 89 | $(ARMGNU)-objcopy rp_midi_out.elf -O srec rp_midi_out.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_blink_gpio4/rp_blink_gpio4.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | Copyright (c) 2017 AZO typesylph@gmail.com 3 | referred to David Welch https://github.com/dwelch67 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 14 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 15 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------*/ 17 | 18 | #include "rp_baremetal.h" 19 | 20 | //------------------------------------------------------------------------ 21 | static inline uint32_t GET32(const intptr_t addr) { 22 | return *(volatile uint32_t*)addr; 23 | } 24 | static inline void PUT32(const intptr_t addr, const uint32_t val) { 25 | *(volatile uint32_t*)addr = val; 26 | } 27 | 28 | //------------------------------------------------------------------------ 29 | void gpio_init(void) { 30 | uint32_t ra; 31 | 32 | /* GPIO function set */ 33 | ra = GET32(BCM283X_GPIO_GPFSEL0); 34 | ra &= ~(7<<12); /* GPIO04 */ 35 | ra |= 1<<12 ; /* output */ 36 | PUT32(BCM283X_GPIO_GPFSEL0, ra); 37 | 38 | /* PullUD disable */ 39 | PUT32(BCM283X_GPIO_GPPUD, 0); 40 | for(ra = 0; ra < 150; ra++) dummy(); 41 | PUT32(BCM283X_GPIO_GPPUDCLK0, (1 << 4)); 42 | for(ra = 0; ra < 150; ra++) dummy(); 43 | PUT32(BCM283X_GPIO_GPPUDCLK0, 0); 44 | } 45 | 46 | //------------------------------------------------------------------------ 47 | int notmain(unsigned int earlypc) { 48 | uint32_t next, light = 1; 49 | 50 | gpio_init(); 51 | 52 | next = azo_uint32_div(GET32(BCM283X_STIMER_CLO), 1000000) * 1000000 + 1000000; 53 | 54 | while(1) { 55 | if(next < GET32(BCM283X_STIMER_CLO)) { 56 | if(light == 1) { 57 | PUT32(BCM283X_GPIO_GPSET0, 1 << 4); 58 | light = 0; 59 | } else { 60 | PUT32(BCM283X_GPIO_GPCLR0, 1 << 4); 61 | light = 1; 62 | } 63 | next += 1000000; 64 | } 65 | } 66 | 67 | return(0); 68 | } 69 | 70 | //------------------------------------------------------------------------- 71 | void c_irq_handler(void) { 72 | } 73 | 74 | //------------------------------------------------------------------------- 75 | 76 | -------------------------------------------------------------------------------- /rp_i2c_ar1010/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_i2c_ar1010.hex kernel.img rp_i2c_ar1010.hex rp_i2c_ar1010.syms rp_i2c_ar1010.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_i2c_ar1010.hex kernel7.img rp_i2c_ar1010.hex rp_i2c_ar1010.syms rp_i2c_ar1010.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_i2c_ar1010.o : rp_i2c_ar1010.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_i2c_ar1010.c -o rp_i2c_ar1010.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_i2c_ar1010.elf : memmap_rp01 vectors.o rp_i2c_ar1010.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_i2c_ar1010.elf : memmap_rp23 vectors.o rp_i2c_ar1010.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_i2c_ar1010.o -T memmap_rp01 -o rp_i2c_ar1010.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_i2c_ar1010.o -T memmap_rp23 -o rp_i2c_ar1010.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_i2c_ar1010.elf > rp_i2c_ar1010.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_i2c_ar1010.elf 76 | $(ARMGNU)-objcopy rp_i2c_ar1010.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_i2c_ar1010.elf 79 | $(ARMGNU)-objcopy rp_i2c_ar1010.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_i2c_ar1010.hex : rp_i2c_ar1010.elf 83 | $(ARMGNU)-objcopy rp_i2c_ar1010.elf -O ihex rp_i2c_ar1010.hex 84 | 85 | rp_i2c_ar1010.syms : rp_i2c_ar1010.elf 86 | $(ARMGNU)-nm -n rp_i2c_ar1010.elf > rp_i2c_ar1010.syms 87 | 88 | rp_i2c_ar1010.srec : rp_i2c_ar1010.elf 89 | $(ARMGNU)-objcopy rp_i2c_ar1010.elf -O srec rp_i2c_ar1010.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_pwm_audio_dma/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),RP1) 37 | gcc : rp_pwm_audio_dma.hex kernel.img rp_pwm_audio_dma.hex rp_pwm_audio_dma.syms rp_pwm_audio_dma.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_pwm_audio_dma.hex kernel7.img rp_pwm_audio_dma.hex rp_pwm_audio_dma.syms rp_pwm_audio_dma.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_pwm_audio_dma.o : rp_pwm_audio_dma.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_pwm_audio_dma.c -o rp_pwm_audio_dma.o 61 | 62 | ifeq ($(AZO_BOARD),RP1) 63 | rp_pwm_audio_dma.elf : memmap_rp01 vectors.o rp_pwm_audio_dma.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_pwm_audio_dma.elf : memmap_rp23 vectors.o rp_pwm_audio_dma.o 66 | endif 67 | ifeq ($(AZO_BOARD),RP1) 68 | $(ARMGNU)-ld vectors.o rp_pwm_audio_dma.o -T memmap_rp01 -o rp_pwm_audio_dma.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_pwm_audio_dma.o -T memmap_rp23 -o rp_pwm_audio_dma.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_pwm_audio_dma.elf > rp_pwm_audio_dma.list 73 | 74 | ifeq ($(AZO_BOARD),RP1) 75 | kernel.img : rp_pwm_audio_dma.elf 76 | $(ARMGNU)-objcopy rp_pwm_audio_dma.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_pwm_audio_dma.elf 79 | $(ARMGNU)-objcopy rp_pwm_audio_dma.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_pwm_audio_dma.hex : rp_pwm_audio_dma.elf 83 | $(ARMGNU)-objcopy rp_pwm_audio_dma.elf -O ihex rp_pwm_audio_dma.hex 84 | 85 | rp_pwm_audio_dma.syms : rp_pwm_audio_dma.elf 86 | $(ARMGNU)-nm -n rp_pwm_audio_dma.elf > rp_pwm_audio_dma.syms 87 | 88 | rp_pwm_audio_dma.srec : rp_pwm_audio_dma.elf 89 | $(ARMGNU)-objcopy rp_pwm_audio_dma.elf -O srec rp_pwm_audio_dma.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_pcm_dma_rec/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_pcm_dma_rec.hex kernel.img rp_pcm_dma_rec.hex rp_pcm_dma_rec.syms rp_pcm_dma_rec.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_pcm_dma_rec.hex kernel7.img rp_pcm_dma_rec.hex rp_pcm_dma_rec.syms rp_pcm_dma_rec.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_pcm_dma_rec.o : rp_pcm_dma_rec.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_pcm_dma_rec.c -o rp_pcm_dma_rec.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_pcm_dma_rec.elf : memmap_rp01 vectors.o rp_pcm_dma_rec.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_pcm_dma_rec.elf : memmap_rp23 vectors.o rp_pcm_dma_rec.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_pcm_dma_rec.o -T memmap_rp01 -o rp_pcm_dma_rec.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_pcm_dma_rec.o -T memmap_rp23 -o rp_pcm_dma_rec.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_pcm_dma_rec.elf > rp_pcm_dma_rec.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_pcm_dma_rec.elf 76 | $(ARMGNU)-objcopy rp_pcm_dma_rec.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_pcm_dma_rec.elf 79 | $(ARMGNU)-objcopy rp_pcm_dma_rec.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_pcm_dma_rec.hex : rp_pcm_dma_rec.elf 83 | $(ARMGNU)-objcopy rp_pcm_dma_rec.elf -O ihex rp_pcm_dma_rec.hex 84 | 85 | rp_pcm_dma_rec.syms : rp_pcm_dma_rec.elf 86 | $(ARMGNU)-nm -n rp_pcm_dma_rec.elf > rp_pcm_dma_rec.syms 87 | 88 | rp_pcm_dma_rec.srec : rp_pcm_dma_rec.elf 89 | $(ARMGNU)-objcopy rp_pcm_dma_rec.elf -O srec rp_pcm_dma_rec.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_spi0_psxpad/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_spi0_psxpad.hex kernel.img rp_spi0_psxpad.hex rp_spi0_psxpad.syms rp_spi0_psxpad.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_spi0_psxpad.hex kernel7.img rp_spi0_psxpad.hex rp_spi0_psxpad.syms rp_spi0_psxpad.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_spi0_psxpad.o : rp_spi0_psxpad.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_spi0_psxpad.c -o rp_spi0_psxpad.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_spi0_psxpad.elf : memmap_rp01 vectors.o rp_spi0_psxpad.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_spi0_psxpad.elf : memmap_rp23 vectors.o rp_spi0_psxpad.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_spi0_psxpad.o -T memmap_rp01 -o rp_spi0_psxpad.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_spi0_psxpad.o -T memmap_rp23 -o rp_spi0_psxpad.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_spi0_psxpad.elf > rp_spi0_psxpad.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_spi0_psxpad.elf 76 | $(ARMGNU)-objcopy rp_spi0_psxpad.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_spi0_psxpad.elf 79 | $(ARMGNU)-objcopy rp_spi0_psxpad.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_spi0_psxpad.hex : rp_spi0_psxpad.elf 83 | $(ARMGNU)-objcopy rp_spi0_psxpad.elf -O ihex rp_spi0_psxpad.hex 84 | 85 | rp_spi0_psxpad.syms : rp_spi0_psxpad.elf 86 | $(ARMGNU)-nm -n rp_spi0_psxpad.elf > rp_spi0_psxpad.syms 87 | 88 | rp_spi0_psxpad.srec : rp_spi0_psxpad.elf 89 | $(ARMGNU)-objcopy rp_spi0_psxpad.elf -O srec rp_spi0_psxpad.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_cyclecounter/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_cyclecounter.hex kernel.img rp_cyclecounter.hex rp_cyclecounter.syms rp_cyclecounter.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_cyclecounter.hex kernel7.img rp_cyclecounter.hex rp_cyclecounter.syms rp_cyclecounter.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_cyclecounter.o : rp_cyclecounter.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_cyclecounter.c -o rp_cyclecounter.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_cyclecounter.elf : memmap_rp01 vectors.o rp_cyclecounter.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_cyclecounter.elf : memmap_rp23 vectors.o rp_cyclecounter.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_cyclecounter.o -T memmap_rp01 -o rp_cyclecounter.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_cyclecounter.o -T memmap_rp23 -o rp_cyclecounter.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_cyclecounter.elf > rp_cyclecounter.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_cyclecounter.elf 76 | $(ARMGNU)-objcopy rp_cyclecounter.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_cyclecounter.elf 79 | $(ARMGNU)-objcopy rp_cyclecounter.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_cyclecounter.hex : rp_cyclecounter.elf 83 | $(ARMGNU)-objcopy rp_cyclecounter.elf -O ihex rp_cyclecounter.hex 84 | 85 | rp_cyclecounter.syms : rp_cyclecounter.elf 86 | $(ARMGNU)-nm -n rp_cyclecounter.elf > rp_cyclecounter.syms 87 | 88 | rp_cyclecounter.srec : rp_cyclecounter.elf 89 | $(ARMGNU)-objcopy rp_cyclecounter.elf -O srec rp_cyclecounter.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_blink_gpio4/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RPZEROW) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZEROW 19 | else ifeq ($(AZO_BOARD),RP1) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 21 | else ifeq ($(AZO_BOARD),RP2) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 23 | else ifeq ($(AZO_BOARD),RP3) 24 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 25 | endif 26 | 27 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 28 | AZO_CPU_SINGLE = 1 29 | ifeq ($(AZO_CPU_SINGLE),1) 30 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 31 | endif 32 | endif 33 | 34 | COPS := -O0 -g3 $(COMMONOPS) 35 | #COPS = -O3 $(COMMONOPS) 36 | ASMOPS := -g3 $(COMMONOPS) 37 | 38 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 39 | gcc : rp_blink_gpio4.hex kernel.img rp_blink_gpio4.hex rp_blink_gpio4.syms rp_blink_gpio4.srec 40 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 41 | gcc : rp_blink_gpio4.hex kernel7.img rp_blink_gpio4.hex rp_blink_gpio4.syms rp_blink_gpio4.srec 42 | endif 43 | 44 | all : gcc 45 | 46 | clean : 47 | rm -f *.o 48 | rm -f *.bin 49 | rm -f *.hex 50 | rm -f *.elf 51 | rm -f *.list 52 | rm -f *.img 53 | rm -f *.bc 54 | rm -f *.syms 55 | rm -f *.srec 56 | rm -f *.clang.opt.s 57 | 58 | vectors.o : vectors.S 59 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 60 | 61 | rp_blink_gpio4.o : rp_blink_gpio4.c 62 | $(ARMGNU)-gcc $(COPS) -c rp_blink_gpio4.c -o rp_blink_gpio4.o 63 | 64 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 65 | rp_blink_gpio4.elf : memmap_rp01 vectors.o rp_blink_gpio4.o 66 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 67 | rp_blink_gpio4.elf : memmap_rp23 vectors.o rp_blink_gpio4.o 68 | endif 69 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 70 | $(ARMGNU)-ld vectors.o rp_blink_gpio4.o -T memmap_rp01 -o rp_blink_gpio4.elf 71 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 72 | $(ARMGNU)-ld vectors.o rp_blink_gpio4.o -T memmap_rp23 -o rp_blink_gpio4.elf 73 | endif 74 | $(ARMGNU)-objdump -D rp_blink_gpio4.elf > rp_blink_gpio4.list 75 | 76 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 77 | kernel.img : rp_blink_gpio4.elf 78 | $(ARMGNU)-objcopy rp_blink_gpio4.elf -O binary kernel.img 79 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 80 | kernel7.img : rp_blink_gpio4.elf 81 | $(ARMGNU)-objcopy rp_blink_gpio4.elf -O binary kernel7.img 82 | endif 83 | 84 | rp_blink_gpio4.hex : rp_blink_gpio4.elf 85 | $(ARMGNU)-objcopy rp_blink_gpio4.elf -O ihex rp_blink_gpio4.hex 86 | 87 | rp_blink_gpio4.syms : rp_blink_gpio4.elf 88 | $(ARMGNU)-nm -n rp_blink_gpio4.elf > rp_blink_gpio4.syms 89 | 90 | rp_blink_gpio4.srec : rp_blink_gpio4.elf 91 | $(ARMGNU)-objcopy rp_blink_gpio4.elf -O srec rp_blink_gpio4.srec 92 | 93 | -------------------------------------------------------------------------------- /rp_jtagenable/README.md: -------------------------------------------------------------------------------- 1 | JTAG enable 2 | =========== 3 | 4 | This program makes Raspberry Pi's ARM JTAG enable to degub. 5 | You need any external JTAG interface probe. 6 | 7 | Connect JTAG interface to below pins. 8 | - pin15 - nTRST(GPIO22/ALT4) 9 | - pin18 - TDO/DI(GPIO24/ALT4) 10 | - pin22 - TCK/SK(GPIO25/ALT4) 11 | - pin37 - TDI/DO(GPIO26/ALT4), or old RP1 pin7 - TDI/DO(GPIO04/ALT5) 12 | - pin13 - TMS/CS(GPIO27/ALT4) 13 | - pin20 - GND(Ground) 14 | 15 | Connect JTAG interface, and run this program, then start debugger. 16 | 17 | ----- 18 | 19 | How to 20 | ------ 21 | For Raspberry Pi Zero/1/2/2_64/3/3_64/4/4_64) Bare Metal code by AZO. 22 | 23 | How to make: 24 | 1. install "arm-none-eabi-gcc" or "gcc-aarch64-linux-gnu"(RP2_64/RP3_64/RP4_64). 25 | 2. Open "Makefile " with texteditor, and change options. 26 | BOARD=OLDRPI/RPZERO/RP1/RP2/RP3/RP3_64/RP4/RP4_64 27 | 3. make 28 | 4. If successfully, output "kernel.img"(RPold1/Zero/1) or "kernel7.img"(RP2/3) or "kernel7l.img"(RP4) or "kernel8.img"(RP2_64/RP3_64/RP4_64). 29 | 30 | How to run: 31 | Put follow files to FAT SD card. 32 | * "bootcode.bin" 33 | * "start.elf" 34 | * "fixup.dat" 35 | * "config.txt" <- config_32bit.txt or config_64bit.txt. 36 | * "kernel.img"(RPold1/Zero/1) or "kernel7.img"(RP2/3) or "kernel7l.img"(RP4) or "kernel8.img"(RP2_64/RP3_64/RP4_64) 37 | 38 | Firmware: 39 | Grub "bootcode.bin" and "start.elf" and "fixup.dat" at 40 | https://github.com/raspberrypi/firmware/tree/master/boot 41 | 42 | ----- 43 | 44 | OpenOCD 45 | ------- 46 | Use newest OpenOCD from repository. 47 | 48 | You can make OpenOCD, include current implemantion for ARMv8. 49 | ```shell 50 | git clone https://git.code.sf.net/p/openocd/code openocd-code 51 | cd openocd-code 52 | ./bootstrap.sh 53 | ./configure --enable-ftdi --enable-bcm2835gpio 54 | make -j4 55 | sudo make install 56 | ``` 57 | and 58 | ```shell 59 | sudo -s 60 | cp cfg/bcm*.cfg /usr/local/share/openocd/scripts/board/ 61 | exit 62 | ``` 63 | 64 | When debug, run follow command. 65 | ```shell 66 | openocd -f interface/yourinterface.cfg -f board/bcm2835.cfg 67 | ``` 68 | 69 | You can use GDB, or 70 | Eclipce + OpenOCD debugging Eclipse plug-in. 71 | http://gnuarmeclipse.github.io/debug/openocd/ 72 | 73 | --- But, I don't success RP4 connection. Please tell me good method :( 74 | 75 | ----- 76 | 77 | Referrence 78 | ---------- 79 | - Boot options in config.txt - Raspberry Pi Documentation https://www.raspberrypi.org/documentation/configuration/config-txt/boot.md 80 | - Peripheral specification https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf 81 | - dwelch67/raspberrypi: Raspberry Pi ARM based bare metal examples https://github.com/dwelch67/raspberrypi 82 | - documentation/README.md at master · 96boards/documentation https://github.com/96boards/documentation/blob/master/ConsumerEdition/HiKey/Configuration/JTAG/README.md 83 | - Olimex ARM-USB-OCD-H / openocd-0.9.0 / libftd2xx1.1.12 / Raspberry Pi 2 / Ubuntu 15.04 https://gist.github.com/tonosaman/62a31e7991a41edb19c5 84 | - Raspberry Pi 4 Bringup - Raspberry Pi https://xihan94.gitbook.io/raspberry-pi/raspberry-pi-4-bringup 85 | 86 | -------------------------------------------------------------------------------- /rp_framebuffer_dma1/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_framebuffer_dma1.hex kernel.img rp_framebuffer_dma1.hex rp_framebuffer_dma1.syms rp_framebuffer_dma1.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_framebuffer_dma1.hex kernel7.img rp_framebuffer_dma1.hex rp_framebuffer_dma1.syms rp_framebuffer_dma1.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_framebuffer_dma1.o : rp_framebuffer_dma1.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_framebuffer_dma1.c -o rp_framebuffer_dma1.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_framebuffer_dma1.elf : memmap_rp01 vectors.o rp_framebuffer_dma1.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_framebuffer_dma1.elf : memmap_rp23 vectors.o rp_framebuffer_dma1.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_framebuffer_dma1.o -T memmap_rp01 -o rp_framebuffer_dma1.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_framebuffer_dma1.o -T memmap_rp23 -o rp_framebuffer_dma1.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_framebuffer_dma1.elf > rp_framebuffer_dma1.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_framebuffer_dma1.elf 76 | $(ARMGNU)-objcopy rp_framebuffer_dma1.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_framebuffer_dma1.elf 79 | $(ARMGNU)-objcopy rp_framebuffer_dma1.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_framebuffer_dma1.hex : rp_framebuffer_dma1.elf 83 | $(ARMGNU)-objcopy rp_framebuffer_dma1.elf -O ihex rp_framebuffer_dma1.hex 84 | 85 | rp_framebuffer_dma1.syms : rp_framebuffer_dma1.elf 86 | $(ARMGNU)-nm -n rp_framebuffer_dma1.elf > rp_framebuffer_dma1.syms 87 | 88 | rp_framebuffer_dma1.srec : rp_framebuffer_dma1.elf 89 | $(ARMGNU)-objcopy rp_framebuffer_dma1.elf -O srec rp_framebuffer_dma1.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_framebuffer_dma8/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | ifeq ($(AZO_MEM_VFP),1) 8 | COMMONOPS := $(COMMONOPS) -mfpu=vfp -DAZO_MEM_VFP 9 | endif 10 | 11 | #AZO_BOARD = RPZERO 12 | #AZO_BOARD = RP1 13 | #AZO_BOARD = RP2 14 | AZO_BOARD = RP3 15 | ifeq ($(AZO_BOARD),RPZERO) 16 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 17 | else ifeq ($(AZO_BOARD),RP1) 18 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 19 | else ifeq ($(AZO_BOARD),RP2) 20 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 21 | else ifeq ($(AZO_BOARD),RP3) 22 | COMMONOPS := $(COMMONOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 23 | endif 24 | 25 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 26 | AZO_CPU_SINGLE = 1 27 | ifeq ($(AZO_CPU_SINGLE),1) 28 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 29 | endif 30 | endif 31 | 32 | COPS := -O0 -g3 $(COMMONOPS) 33 | #COPS = -O3 $(COMMONOPS) 34 | ASMOPS := -g3 $(COMMONOPS) 35 | 36 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 37 | gcc : rp_framebuffer_dma8.hex kernel.img rp_framebuffer_dma8.hex rp_framebuffer_dma8.syms rp_framebuffer_dma8.srec 38 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 39 | gcc : rp_framebuffer_dma8.hex kernel7.img rp_framebuffer_dma8.hex rp_framebuffer_dma8.syms rp_framebuffer_dma8.srec 40 | endif 41 | 42 | all : gcc 43 | 44 | clean : 45 | rm -f *.o 46 | rm -f *.bin 47 | rm -f *.hex 48 | rm -f *.elf 49 | rm -f *.list 50 | rm -f *.img 51 | rm -f *.bc 52 | rm -f *.syms 53 | rm -f *.srec 54 | rm -f *.clang.opt.s 55 | 56 | vectors.o : vectors.S 57 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 58 | 59 | rp_framebuffer_dma8.o : rp_framebuffer_dma8.c 60 | $(ARMGNU)-gcc $(COPS) -c rp_framebuffer_dma8.c -o rp_framebuffer_dma8.o 61 | 62 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 63 | rp_framebuffer_dma8.elf : memmap_rp01 vectors.o rp_framebuffer_dma8.o 64 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 65 | rp_framebuffer_dma8.elf : memmap_rp23 vectors.o rp_framebuffer_dma8.o 66 | endif 67 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 68 | $(ARMGNU)-ld vectors.o rp_framebuffer_dma8.o -T memmap_rp01 -o rp_framebuffer_dma8.elf 69 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 70 | $(ARMGNU)-ld vectors.o rp_framebuffer_dma8.o -T memmap_rp23 -o rp_framebuffer_dma8.elf 71 | endif 72 | $(ARMGNU)-objdump -D rp_framebuffer_dma8.elf > rp_framebuffer_dma8.list 73 | 74 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 75 | kernel.img : rp_framebuffer_dma8.elf 76 | $(ARMGNU)-objcopy rp_framebuffer_dma8.elf -O binary kernel.img 77 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 78 | kernel7.img : rp_framebuffer_dma8.elf 79 | $(ARMGNU)-objcopy rp_framebuffer_dma8.elf -O binary kernel7.img 80 | endif 81 | 82 | rp_framebuffer_dma8.hex : rp_framebuffer_dma8.elf 83 | $(ARMGNU)-objcopy rp_framebuffer_dma8.elf -O ihex rp_framebuffer_dma8.hex 84 | 85 | rp_framebuffer_dma8.syms : rp_framebuffer_dma8.elf 86 | $(ARMGNU)-nm -n rp_framebuffer_dma8.elf > rp_framebuffer_dma8.syms 87 | 88 | rp_framebuffer_dma8.srec : rp_framebuffer_dma8.elf 89 | $(ARMGNU)-objcopy rp_framebuffer_dma8.elf -O srec rp_framebuffer_dma8.srec 90 | 91 | -------------------------------------------------------------------------------- /rp_framebuffer/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ARMGNU ?= arm-none-eabi 3 | 4 | COMMONOPS = -Wall -nostdlib -nostartfiles -ffreestanding 5 | 6 | #AZO_MEM_VFP = 1 7 | 8 | #AZO_BOARD = RPZERO 9 | #AZO_BOARD = RP1 10 | #AZO_BOARD = RP2 11 | AZO_BOARD = RP3 12 | #AZO_BOARD = RP4 13 | ifeq ($(AZO_BOARD),RPZERO) 14 | COMMONOPS := $(COMMONOPS) -march=armv6zk -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -fpic -ffreestanding -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 15 | ifeq ($(AZO_MEM_VFP),1) 16 | COMMONOPS := $(COMMONOPS) -mfloat-abi=hard -mfpu=vfp -DAZO_MEM_VFP 17 | endif 18 | else ifeq ($(AZO_BOARD),RP1) 19 | COMMONOPS := $(COMMONOPS) -march=armv6zk -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -fpic -ffreestanding -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 20 | ifeq ($(AZO_MEM_VFP),1) 21 | COMMONOPS := $(COMMONOPS) -mfloat-abi=hard -mfpu=vfp -DAZO_MEM_VFP 22 | endif 23 | else ifeq ($(AZO_BOARD),RP2) 24 | COMMONOPS := $(COMMONOPS) -mcpu=cortex-a7 -fpic -ffreestanding -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 25 | ifeq ($(AZO_MEM_VFP),1) 26 | COMMONOPS := $(COMMONOPS) -mfpu=neon-vfpv4 -mfloat-abi=hard -DAZO_MEM_VFP 27 | endif 28 | else ifeq ($(AZO_BOARD),RP3) 29 | COMMONOPS := $(COMMONOPS) -march=armv8-a -mtune=cortex-a53 -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 30 | ifeq ($(AZO_MEM_VFP),1) 31 | COMMONOPS := $(COMMONOPS) -mfpu=neon-fp-armv8 -mfloat-abi=hard -DAZO_MEM_VFP 32 | endif 33 | else ifeq ($(AZO_BOARD),RP4) 34 | COMMONOPS := $(COMMONOPS) -mcpu=cortex-a72 -mtune=cortex-a72 -DAZO_CHIP_BCM2711 -DAZO_BOARD_RP4 35 | ifeq ($(AZO_MEM_VFP),1) 36 | COMMONOPS := $(COMMONOPS) -mfpu=neon-fp-armv8 -mfloat-abi=hard -DAZO_MEM_VFP 37 | endif 38 | endif 39 | 40 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3 RP4)) 41 | AZO_CPU_SINGLE = 1 42 | ifeq ($(AZO_CPU_SINGLE),1) 43 | COMMONOPS := $(COMMONOPS) -DAZO_CPU_SINGLE 44 | endif 45 | endif 46 | 47 | COPS := -O0 -g3 $(COMMONOPS) 48 | #COPS = -O3 $(COMMONOPS) 49 | ASMOPS := -g3 $(COMMONOPS) 50 | 51 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 52 | gcc : rp_framebuffer.hex kernel.img rp_framebuffer.hex rp_framebuffer.syms rp_framebuffer.srec 53 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3 RP4)) 54 | gcc : rp_framebuffer.hex kernel7.img rp_framebuffer.hex rp_framebuffer.syms rp_framebuffer.srec 55 | endif 56 | 57 | all : gcc 58 | 59 | clean : 60 | rm -f *.o 61 | rm -f *.bin 62 | rm -f *.hex 63 | rm -f *.elf 64 | rm -f *.list 65 | rm -f *.img 66 | rm -f *.bc 67 | rm -f *.syms 68 | rm -f *.srec 69 | rm -f *.clang.opt.s 70 | 71 | vectors.o : vectors.S 72 | $(ARMGNU)-gcc $(ASMOPS) -c vectors.S -o vectors.o 73 | 74 | rp_framebuffer.o : rp_framebuffer.c 75 | $(ARMGNU)-gcc $(COPS) -c rp_framebuffer.c -o rp_framebuffer.o 76 | 77 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 78 | rp_framebuffer.elf : memmap_rp01 vectors.o rp_framebuffer.o 79 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3 RP4)) 80 | rp_framebuffer.elf : memmap_rp23 vectors.o rp_framebuffer.o 81 | endif 82 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 83 | $(ARMGNU)-ld vectors.o rp_framebuffer.o -T memmap_rp01 -o rp_framebuffer.elf 84 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3 RP4)) 85 | $(ARMGNU)-ld vectors.o rp_framebuffer.o -T memmap_rp23 -o rp_framebuffer.elf 86 | endif 87 | $(ARMGNU)-objdump -D rp_framebuffer.elf > rp_framebuffer.list 88 | 89 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 90 | kernel.img : rp_framebuffer.elf 91 | $(ARMGNU)-objcopy rp_framebuffer.elf -O binary kernel.img 92 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3 RP4)) 93 | kernel7.img : rp_framebuffer.elf 94 | $(ARMGNU)-objcopy rp_framebuffer.elf -O binary kernel7.img 95 | endif 96 | 97 | rp_framebuffer.hex : rp_framebuffer.elf 98 | $(ARMGNU)-objcopy rp_framebuffer.elf -O ihex rp_framebuffer.hex 99 | 100 | rp_framebuffer.syms : rp_framebuffer.elf 101 | $(ARMGNU)-nm -n rp_framebuffer.elf > rp_framebuffer.syms 102 | 103 | rp_framebuffer.srec : rp_framebuffer.elf 104 | $(ARMGNU)-objcopy rp_framebuffer.elf -O srec rp_framebuffer.srec 105 | 106 | -------------------------------------------------------------------------------- /rp_uart/rp_uart.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | Copyright (c) 2016 AZO typesylph@gmail.com 3 | referred to David Welch https://github.com/dwelch67 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 14 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 15 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------*/ 17 | 18 | #include "rp_baremetal.h" 19 | 20 | //------------------------------------------------------------------------ 21 | void uart_putc(uint8_t c) { 22 | while((GET32(BCM283X_AUX_MU_LSR_REG) & 0x20) == 0); 23 | PUT32(BCM283X_AUX_MU_IO_REG,c); 24 | } 25 | 26 | //------------------------------------------------------------------------ 27 | uint8_t uart_getc(void) { 28 | while((GET32(BCM283X_AUX_MU_LSR_REG) & 0x01) == 0); 29 | return(GET32(BCM283X_AUX_MU_IO_REG)); 30 | } 31 | 32 | //------------------------------------------------------------------------ 33 | void uart_init(void) { 34 | uint32_t ra; 35 | 36 | /* GPIO function set */ 37 | ra = GET32(BCM283X_GPIO_GPFSEL1); 38 | ra &= ~(7<<12); /* GPIO14 */ 39 | ra |= 2<<12 ; /* ALT5 */ 40 | ra &= ~(7<<15); /* GPIO15 */ 41 | ra |= 2<<15 ; /* ALT5 */ 42 | PUT32(BCM283X_GPIO_GPFSEL1, ra); 43 | 44 | /* PullUD disable */ 45 | PUT32(BCM283X_GPIO_GPPUD, 0); 46 | for(ra = 0; ra < 150; ra++) dummy(); 47 | PUT32(BCM283X_GPIO_GPPUDCLK0, (1 << 14) | (1 << 15)); 48 | for(ra = 0; ra < 150; ra++) dummy(); 49 | PUT32(BCM283X_GPIO_GPPUDCLK0, 0); 50 | 51 | PUT32(BCM283X_AUX_ENABLES, 1); /* Enable UART1 */ 52 | PUT32(BCM283X_AUX_MU_IER_REG, 0); /* Disable interrupt */ 53 | PUT32(BCM283X_AUX_MU_CNTL_REG, 0); /* Disable Transmitter and Receiver */ 54 | PUT32(BCM283X_AUX_MU_LCR_REG, 3); /* Works in 8-bit mode */ 55 | PUT32(BCM283X_AUX_MU_MCR_REG, 0); /* Disable RTS */ 56 | PUT32(BCM283X_AUX_MU_IIR_REG, 0xC6); /* Enable FIFO, Clear FIFO */ 57 | PUT32(BCM283X_AUX_MU_BAUD_REG, 270); /* 115200 = system clock 250MHz / (8 * (baud + 1)), baud = 270 */ 58 | PUT32(BCM283X_AUX_MU_CNTL_REG, 3); /* Enable Transmitter and Receiver */ 59 | } 60 | //------------------------------------------------------------------------ 61 | void hexstrings(uint32_t d) { 62 | uint32_t rb; 63 | uint32_t rc; 64 | 65 | rb = 32; 66 | while(1) { 67 | rb -= 4; 68 | rc = (d >> rb) & 0xF; 69 | if(rc > 9) rc += 0x37; else rc += 0x30; 70 | uart_putc(rc); 71 | if(rb == 0) break; 72 | } 73 | uart_putc(0x20); 74 | } 75 | 76 | //------------------------------------------------------------------------ 77 | void hexstring(uint32_t d) { 78 | hexstrings(d); 79 | uart_putc(0x0D); 80 | uart_putc(0x0A); 81 | } 82 | 83 | //------------------------------------------------------------------------ 84 | int notmain(unsigned int earlypc) { 85 | PUT32(BCM283X_IRQ_DISABLE1, 1 << 29); /* Disable interrupt */ 86 | 87 | uart_init(); 88 | 89 | PUT32(BCM283X_AUX_MU_IER_REG, 0x5); /* Enable receive interrupt */ 90 | 91 | hexstring(0x12345678); 92 | 93 | PUT32(BCM283X_IRQ_ENABLE1, 1 << 29); /* Enable interrupt */ 94 | 95 | arm_irq_enable(); 96 | 97 | while(1); 98 | 99 | return(0); 100 | } 101 | 102 | //------------------------------------------------------------------------- 103 | void c_irq_handler(void) { 104 | uart_putc(uart_getc()); 105 | } 106 | 107 | //------------------------------------------------------------------------- 108 | 109 | -------------------------------------------------------------------------------- /rp_midi_out/rp_midi_out.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | Copyright (c) 2016 AZO typesylph@gmail.com 3 | referred to David Welch https://github.com/dwelch67 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 14 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 15 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------*/ 17 | 18 | #include "rp_baremetal.h" 19 | 20 | /* GM system on */ 21 | const uint8_t azo_midi_gmsystemon[6] = {0xF0, 0x7E, 0x7F, 0x09, 0x01, 0xF7}; 22 | /* C major */ 23 | const uint8_t azo_midi_keys[8] = {0x3C, 0x3E, 0x40, 0x41, 0x43, 0x45, 0x47, 0x48}; 24 | 25 | //------------------------------------------------------------------------- 26 | void c_irq_handler(void) { 27 | } 28 | 29 | //------------------------------------------------------------------------ 30 | void uart_putc(uint8_t c) { 31 | while((GET32(BCM283X_AUX_MU_LSR_REG) & 0x20) == 0); 32 | PUT32(BCM283X_AUX_MU_IO_REG,c); 33 | } 34 | 35 | //------------------------------------------------------------------------ 36 | void uart_init(void) { 37 | uint32_t ra; 38 | 39 | /* GPIO function set */ 40 | ra = GET32(BCM283X_GPIO_GPFSEL1); 41 | ra &= ~(7<<12); /* GPIO14 */ 42 | ra |= 2<<12 ; /* ALT5 */ 43 | ra &= ~(7<<15); /* GPIO15 */ 44 | ra |= 2<<15 ; /* ALT5 */ 45 | PUT32(BCM283X_GPIO_GPFSEL1, ra); 46 | 47 | /* PullUD disable */ 48 | PUT32(BCM283X_GPIO_GPPUD, 0); 49 | for(ra = 0; ra < 150; ra++) dummy(); 50 | PUT32(BCM283X_GPIO_GPPUDCLK0, (1 << 14) | (1 << 15)); 51 | for(ra = 0; ra < 150; ra++) dummy(); 52 | PUT32(BCM283X_GPIO_GPPUDCLK0, 0); 53 | 54 | PUT32(BCM283X_AUX_ENABLES, 1); /* Enable UART1 */ 55 | PUT32(BCM283X_AUX_MU_IER_REG, 0); /* Disable interrupt */ 56 | PUT32(BCM283X_AUX_MU_CNTL_REG, 0); /* Disable Transmitter and Receiver */ 57 | PUT32(BCM283X_AUX_MU_LCR_REG, 3); /* Works in 8-bit mode */ 58 | PUT32(BCM283X_AUX_MU_MCR_REG, 0); /* Disable RTS */ 59 | PUT32(BCM283X_AUX_MU_IIR_REG, 0xC6); /* Enable FIFO, Clear FIFO */ 60 | PUT32(BCM283X_AUX_MU_BAUD_REG, 999); /* 31250 = system clock 250MHz / (8 * (baud + 1)), baud = 999 */ 61 | PUT32(BCM283X_AUX_MU_CNTL_REG, 3); /* Enable Transmitter and Receiver */ 62 | } 63 | 64 | //------------------------------------------------------------------------ 65 | int notmain(unsigned int earlypc) { 66 | uint32_t time; 67 | uint32_t key = 0; 68 | 69 | /* UART to MIDI */ 70 | uart_init(); 71 | 72 | time = GET32(BCM283X_STIMER_CLO); 73 | 74 | /* GM system on */ 75 | uart_putc(azo_midi_gmsystemon[0]); 76 | uart_putc(azo_midi_gmsystemon[1]); 77 | uart_putc(azo_midi_gmsystemon[2]); 78 | uart_putc(azo_midi_gmsystemon[3]); 79 | uart_putc(azo_midi_gmsystemon[4]); 80 | uart_putc(azo_midi_gmsystemon[5]); 81 | 82 | /* wait 100ms */ 83 | while(GET32(BCM283X_STIMER_CLO) < time + 100000); 84 | 85 | while(1) { 86 | time = GET32(BCM283X_STIMER_CLO); 87 | 88 | /* note on */ 89 | uart_putc(0x90); 90 | uart_putc(azo_midi_keys[key]); 91 | uart_putc(0x7F); 92 | 93 | /* wait 500ms = 120BPM */ 94 | while(GET32(BCM283X_STIMER_CLO) < time + 500000); 95 | 96 | /* note off */ 97 | uart_putc(0x80); 98 | uart_putc(azo_midi_keys[key]); 99 | uart_putc(0x7F); 100 | 101 | key++; 102 | if(key >= 8) key = 0; 103 | } 104 | 105 | return(0); 106 | } 107 | 108 | //------------------------------------------------------------------------- 109 | 110 | -------------------------------------------------------------------------------- /rp_jtagenable/Makefile: -------------------------------------------------------------------------------- 1 | AZO_BOARD = OLDRP1 2 | #AZO_BOARD = RPZERO 3 | #AZO_BOARD = RP1 4 | #AZO_BOARD = RP2 5 | #AZO_BOARD = RP2_64 6 | #AZO_BOARD = RP3 7 | #AZO_BOARD = RP3_64 8 | #AZO_BOARD = RP4 9 | #AZO_BOARD = RP4_64 10 | 11 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),OLDRP1 RPZERO RP1 RP2 RP3 RP4)) 12 | ARMGNU ?= arm-none-eabi 13 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2_64 RP3_64 RP4_64)) 14 | ARMGNU ?= aarch64-linux-gnu 15 | endif 16 | 17 | ASMOPS = -g3 18 | 19 | ifeq ($(AZO_BOARD),RPZERO) 20 | ASMOPS := $(ASMOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RPZERO 21 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP1 OLDRP1)) 22 | ASMOPS := $(ASMOPS) -DAZO_CHIP_BCM2835 -DAZO_BOARD_RP1 23 | else ifeq ($(AZO_BOARD),RP2) 24 | ASMOPS := $(ASMOPS) -DAZO_CHIP_BCM2836 -DAZO_BOARD_RP2 25 | else ifeq ($(AZO_BOARD),RP3) 26 | ASMOPS := $(ASMOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3 27 | else ifeq ($(AZO_BOARD),RP3_64) 28 | ASMOPS := $(ASMOPS) -DAZO_CHIP_BCM2837 -DAZO_BOARD_RP3_64 29 | else ifeq ($(AZO_BOARD),RP4) 30 | ASMOPS := $(ASMOPS) -DAZO_CHIP_BCM2711 -DAZO_BOARD_RP4 31 | else ifeq ($(AZO_BOARD),RP4_64) 32 | ASMOPS := $(ASMOPS) -DAZO_CHIP_BCM2711 -DAZO_BOARD_RP4_64 33 | endif 34 | 35 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),OLDRP1 RPZERO RP1)) 36 | gcc : kernel.img rp_jtagenable.hex rp_jtagenable.syms rp_jtagenable.srec 37 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 38 | gcc : kernel7.img rp_jtagenable.hex rp_jtagenable.syms rp_jtagenable.srec 39 | else ifeq ($(AZO_BOARD),RP4) 40 | gcc : kernel7l.img rp_jtagenable.hex rp_jtagenable.syms rp_jtagenable.srec 41 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2_64 RP3_64 RP4_64)) 42 | gcc : kernel8.img rp_jtagenable.hex rp_jtagenable.syms rp_jtagenable.srec 43 | endif 44 | 45 | all : gcc 46 | 47 | clean : 48 | rm -f *.o 49 | rm -f *.bin 50 | rm -f *.hex 51 | rm -f *.elf 52 | rm -f *.list 53 | rm -f *.img 54 | rm -f *.bc 55 | rm -f *.syms 56 | rm -f *.srec 57 | rm -f *.clang.opt.s 58 | 59 | rp_jtagenable_32.o : rp_jtagenable_32.S 60 | $(ARMGNU)-gcc $(ASMOPS) -c rp_jtagenable_32.S -o rp_jtagenable_32.o 61 | rp_jtagenable_32_oldrp1.o : rp_jtagenable_32_oldrp1.S 62 | $(ARMGNU)-gcc $(ASMOPS) -c rp_jtagenable_32_oldrp1.S -o rp_jtagenable_32_oldrp1.o 63 | rp_jtagenable_64.o : rp_jtagenable_64.S 64 | $(ARMGNU)-gcc $(ASMOPS) -c rp_jtagenable_64.S -o rp_jtagenable_64.o 65 | 66 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 67 | rp_jtagenable.elf : memmap rp_jtagenable_32.o 68 | else ifeq ($(AZO_BOARD),OLDRP1) 69 | rp_jtagenable.elf : memmap rp_jtagenable_32_oldrp1.o 70 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3 RP4)) 71 | rp_jtagenable.elf : memmap rp_jtagenable_32.o 72 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2_64 RP3_64 RP4_64)) 73 | rp_jtagenable.elf : memmap rp_jtagenable_64.o 74 | endif 75 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1)) 76 | $(ARMGNU)-ld rp_jtagenable_32.o -T memmap -o rp_jtagenable.elf 77 | else ifeq ($(AZO_BOARD),OLDRP1) 78 | $(ARMGNU)-ld rp_jtagenable_32_oldrp1.o -T memmap -o rp_jtagenable.elf 79 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3 RP4)) 80 | $(ARMGNU)-ld rp_jtagenable_32.o -T memmap -o rp_jtagenable.elf 81 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2_64 RP3_64 RP4_64)) 82 | $(ARMGNU)-ld rp_jtagenable_64.o -T memmap -o rp_jtagenable.elf 83 | endif 84 | $(ARMGNU)-objdump -D rp_jtagenable.elf > rp_jtagenable.list 85 | 86 | ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RPZERO RP1 OLDRP1)) 87 | kernel.img : rp_jtagenable.elf 88 | $(ARMGNU)-objcopy rp_jtagenable.elf -O binary kernel.img 89 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2 RP3)) 90 | kernel7.img : rp_jtagenable.elf 91 | $(ARMGNU)-objcopy rp_jtagenable.elf -O binary kernel7.img 92 | else ifeq ($(AZO_BOARD),RP4) 93 | kernel7l.img : rp_jtagenable.elf 94 | $(ARMGNU)-objcopy rp_jtagenable.elf -O binary kernel7l.img 95 | else ifeq ($(AZO_BOARD),$(filter $(AZO_BOARD),RP2_64 RP3_64 RP4_64)) 96 | kernel8.img : rp_jtagenable.elf 97 | $(ARMGNU)-objcopy rp_jtagenable.elf -O binary kernel8.img 98 | endif 99 | 100 | rp_jtagenable.hex : rp_jtagenable.elf 101 | $(ARMGNU)-objcopy rp_jtagenable.elf -O ihex rp_jtagenable.hex 102 | 103 | rp_jtagenable.syms : rp_jtagenable.elf 104 | $(ARMGNU)-nm -n rp_jtagenable.elf > rp_jtagenable.syms 105 | 106 | rp_jtagenable.srec : rp_jtagenable.elf 107 | $(ARMGNU)-objcopy rp_jtagenable.elf -O srec rp_jtagenable.srec 108 | 109 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Raspberry Pi Zero/1/2/3 Bare Metal sample by AZO 2 | ================================================ 3 | 4 | [![BuyMeACoffee](https://img.shields.io/badge/-Buy%20Me%20a%20Coffee-ffdd00?style=flat-square&logo=buymeacoffee&logoColor=black)](https://coff.ee/azo234) 5 | [![](https://img.shields.io/static/v1?label=Sponsor&message=❤️&logo=github-sponsors&color=lightgrey&style=for-the-badge)](https://github.com/sponsors/azo234) 6 | 7 | For Raspberry Pi Zero/1/2/3 Bare Metal code by AZO(Tomohiro Yoshidomi). 8 | Twitter:@AZO234 E-Mail:typesylph@gmail.com 9 | http://domisan.sakura.ne.jp 10 | 11 | How to make: 12 | 1. install "arm-none-eabi-gcc". 13 | 2. Open "Makefile " with texteditor, and change options. 14 | BOARD=RPZERO/RP1/RP2/RP3 15 | 3. make 16 | 4. If successfully, output "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3). 17 | 18 | How to run: 19 | Put follow files to FAT SD card. 20 | * "bootcode.bin" 21 | * "start.elf" 22 | * "config.txt" <- config_rp01.txt or config_rp23.txt 23 | * "kernel.img"(RPZero/1) or "kernel7.img"(RP2/3) 24 | 25 | Firmware: 26 | Grub "bootcode.bin" and "start.elf" at 27 | https://github.com/raspberrypi/firmware/tree/master/boot 28 | 29 | Reference 30 | --------- 31 | - dwelch67/raspberrypi: Raspberry Pi ARM based bare metal examples 32 | https://github.com/dwelch67/raspberrypi 33 | - PeterLemon/RaspberryPi: Raspberry Pi Bare Metal Assembly Programming 34 | https://github.com/PeterLemon/RaspberryPi 35 | 36 | ----- 37 | 38 | - CONFIG.TXT 39 | https://www.raspberrypi.org/documentation/configuration/config-txt.md 40 | 41 | ----- 42 | 43 | - Peripheral specification 44 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf 45 | - BCM2835 datasheet errata - eLinux.org 46 | http://elinux.org/BCM2835_datasheet_errata 47 | - ARM11 MPCore Processor Technical Reference Manual 48 | http://infocenter.arm.com/help/topic/com.arm.doc.ddi0360f/DDI0360F_arm11_mpcore_r2p0_trm.pdf 49 | - ARM1176JZF-S Technical Reference Manual 50 | http://infocenter.arm.com/help/topic/com.arm.doc.ddi0301h/ddi0301h_arm1176jzfs_r0p7_trm.pdf 51 | - SCHEMATICS RASPBERRY PI MODEL B+ 52 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/Raspberry-Pi-B-Plus-V1.2-Schematics.pdf 53 | - SCHEMATICS RASPBERRY PI 1 MODEL A AND B 54 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/Raspberry-Pi-Rev-2.1-Model-AB-Schematics.pdf 55 | - MECHANICAL DRAWINGS RASPBERRY PI 1 MODEL B+ 56 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/mechanical/Raspberry-Pi-B-Plus-V1.2-Mechanical-Drawing.pdf 57 | - DPI (PARALLEL DISPLAY INTERFACE) 58 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/dpi/README.md 59 | - CAMERA MODULE 60 | https://www.raspberrypi.org/documentation/hardware/camera/README.md 61 | - SMSC LAN9512 62 | http://ww1.microchip.com/downloads/en/DeviceDoc/9512.pdf 63 | - Raspberry Pi VideoCore APIs 64 | http://elinux.org/Raspberry_Pi_VideoCore_APIs 65 | - Github raspberrypi/firmware 66 | https://github.com/raspberrypi/firmware 67 | - Official Broadcom VideoCore IV 3D Architecture Reference 68 | http://www.broadcom.com/docs/support/videocore/VideoCoreIV-AG100-R.pdf 69 | 70 | ----- 71 | 72 | - BCM2836 ARM-local peripherals 73 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf 74 | - Cortex™-A7 MPCore™ Technical Reference Manual 75 | http://infocenter.arm.com/help/topic/com.arm.doc.ddi0464f/DDI0464F_cortex_a7_mpcore_r0p5_trm.pdf 76 | - Cortex™-A7 Floating-Point Unit Technical Reference Manual 77 | http://infocenter.arm.com/help/topic/com.arm.doc.ddi0463f/DDI0463F_cortex_a7_fpu_r0p5_trm.pdf 78 | - Cortex™-A7 NEON™ Media Processing Engine Technical Reference Manual 79 | http://infocenter.arm.com/help/topic/com.arm.doc.ddi0462f/DDI0462F_cortex_a7_neon_mpe_r0p5_trm.pdf 80 | 81 | ----- 82 | 83 | - ARM® Cortex®-A53 MPCore Processor Technical Reference Manual 84 | http://infocenter.arm.com/help/topic/com.arm.doc.ddi0500g/DDI0500G_cortex_a53_trm.pdf 85 | - ARM® Cortex®-A53 MPCore Processor Advanced SIMD and Floating-point Extension Technical Reference Manual 86 | http://infocenter.arm.com/help/topic/com.arm.doc.ddi0502g/DDI0502G_cortex_a53_fpu_trm.pdf 87 | - ARM® Cortex®-A53 MPCore Processor Cryptography Extension Technical Reference Manual 88 | http://infocenter.arm.com/help/topic/com.arm.doc.ddi0501f/DDI0501F_cortex_a53_cryptography_trm.pdf 89 | - SCHEMATICS RASPBERRY PI 3 MODEL B 90 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/RPI-3B-V1_2-SCHEMATIC-REDUCED.pdf 91 | - MECHANICAL DRAWINGS RASPBERRY PI 3 92 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/mechanical/RPI-3B-V1_2.pdf 93 | 94 | ----- 95 | 96 | - MECHANICAL DRAWINGS RASPBERRY PI ZERO (V1.2) 97 | https://www.raspberrypi.org/documentation/hardware/raspberrypi/mechanical/rpi-zero-v1_2_dimensions.pdf 98 | 99 | -------------------------------------------------------------------------------- /rp_clockgen/rp_clockgen.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | Copyright (c) 2016 AZO typesylph@gmail.com 3 | referred to David Welch https://github.com/dwelch67 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 14 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 15 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------*/ 17 | 18 | #include "rp_baremetal.h" 19 | 20 | //------------------------------------------------------------------------- 21 | void c_irq_handler(void) 22 | { 23 | } 24 | 25 | //------------------------------------------------------------------------ 26 | void gpclk_init(void) { 27 | uint32_t ra; 28 | 29 | /* GPIO function set */ 30 | ra = GET32(BCM283X_GPIO_GPFSEL0); 31 | ra &= ~(7<<12); /* GPIO4 GPCLK0 */ 32 | ra |= 4<<12 ; /* ALT0 */ 33 | ra &= ~(7<<15); /* GPIO5 GPCLK1 */ 34 | ra |= 4<<15 ; /* ALT0 */ 35 | ra &= ~(7<<18); /* GPIO6 GPCLK2 */ 36 | ra |= 4<<18 ; /* ALT0 */ 37 | PUT32(BCM283X_GPIO_GPFSEL0, ra); 38 | 39 | /* PullUD disable */ 40 | PUT32(BCM283X_GPIO_GPPUD, 0); /* disable pullUD */ 41 | for(ra = 0; ra < 150; ra++) dummy(); /* wait 150 cycles */ 42 | PUT32(BCM283X_GPIO_GPPUDCLK0, (1 << 4) | (1 << 5) | (1 << 6)); /* GPIO4/5/6 pullUD disable */ 43 | for(ra = 0; ra < 150; ra++) dummy(); /* wait 150 cycles */ 44 | PUT32(BCM283X_GPIO_GPPUDCLK0, 0); /* remove the clock */ 45 | } 46 | 47 | //------------------------------------------------------------------------ 48 | int notmain(unsigned int earlypc) { 49 | gpclk_init(); 50 | 51 | /* Clock setting */ 52 | /* 53 | 0: GND 54 | 1: oscillator 19.2 MHz 55 | 2: testdebug0 56 | 3: testdebug1 57 | 4: PLLA 650 MHz per 58 | *: PLLB 400 MHz 59 | 5: PLLC 200 MHz per (changes with overclock settings to 1000 MHz) 60 | 6: PLLD 500 MHz per 61 | 7: HDMI auxiliary 216 MHz 62 | 63 | GPCLK0, GPCLK1, and GPCLK2. 64 | Don't use GPCLK1 (it's probably used for the Ethernet clock). 65 | */ 66 | /* GPnCLK 8.1920MHz: PLLD 500 MHz / 8.1920MHz = 61.0351 : I = 61 : F = (0.0351 * 4096) = 143 */ 67 | /* GPnCLK 11.2896MHz: PLLD 500 MHz / 11.2896MHz = 44.2885 : I = 44 : F = (0.2885 * 4096) = 1181 */ 68 | /* GPnCLK 12.2880MHz: PLLD 500 MHz / 12.2880MHz = 40.6901 : I = 40 : F = (0.6901 * 4096) = 2826 */ 69 | /* GPnCLK 16.3840MHz: PLLD 500 MHz / 16.3840MHz = 30.5175 : I = 30 : F = (0.5175 * 4096) = 2119 */ 70 | /* GPnCLK 16.9344MHz: PLLD 500 MHz / 16.9344MHz = 29.5256 : I = 29 : F = (0.5256 * 4096) = 2152 */ 71 | /* GPnCLK 18.4320MHz: PLLD 500 MHz / 18.4320MHz = 27.1267 : I = 27 : F = (0.1267 * 4096) = 518 */ 72 | /* GPnCLK 22.5792MHz: PLLD 500 MHz / 22.5792MHz = 22.1442 : I = 22 : F = (0.1442 * 4096) = 590 */ 73 | /* GPnCLK 24.5760MHz: PLLD 500 MHz / 24.5760MHz = 20.3450 : I = 20 : F = (0.3450 * 4096) = 1413 */ 74 | /* GPnCLK 32.7680MHz: PLLD 500 MHz / 32.7680MHz = 15.2587 : I = 15 : F = (0.2587 * 4096) = 1059 */ 75 | /* GPnCLK 33.8688MHz: PLLD 500 MHz / 33.8688MHz = 14.7628 : I = 14 : F = (0.7628 * 4096) = 3124 */ 76 | /* GPnCLK 36.8640MHz: PLLD 500 MHz / 36.8640MHz = 13.5633 : I = 13 : F = (0.5633 * 4096) = 2307 */ 77 | /* GPnCLK 45.1584MHz: PLLD 500 MHz / 45.1584MHz = 11.0721 : I = 11 : F = (0.0721 * 4096) = 295 */ 78 | /* GPnCLK 49.1520MHz: PLLD 500 MHz / 49.1520MHz = 10.1725 : I = 10 : F = (0.1725 * 4096) = 706 */ 79 | 80 | /* GP0CLK 24.5760MHz */ 81 | PUT32(BCM283X_CM_GP0CTL, BCM283X_CM_PASSWORD + 0x26); /* Disable Clock Generator, oscillator */ 82 | PUT32(BCM283X_CM_GP0DIV, BCM283X_CM_PASSWORD + 0x14585); /* Div by I=20:F=1413 */ 83 | PUT32(BCM283X_CM_GP0CTL, BCM283X_CM_PASSWORD + 0x216); /* Enable Clock Generator, 1stage MASH, PLLD */ 84 | /* GP2CLK 22.5792MHz */ 85 | PUT32(BCM283X_CM_GP2CTL, BCM283X_CM_PASSWORD + 0x26); /* Disable Clock Generator, oscillator */ 86 | PUT32(BCM283X_CM_GP2DIV, BCM283X_CM_PASSWORD + 0x161FD); /* Div by I=22:F= 590 */ 87 | PUT32(BCM283X_CM_GP2CTL, BCM283X_CM_PASSWORD + 0x216); /* Enable Clock Generator, 1stage MASH, PLLD */ 88 | 89 | while(1); 90 | 91 | return(0); 92 | } 93 | 94 | //------------------------------------------------------------------------- 95 | 96 | -------------------------------------------------------------------------------- /rp_cyclecounter/rp_cyclecounter.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | Copyright (c) 2016 AZO typesylph@gmail.com 3 | referred to David Welch https://github.com/dwelch67 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 14 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 15 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------*/ 17 | 18 | #include "rp_baremetal.h" 19 | 20 | //------------------------------------------------------------------------- 21 | void c_irq_handler(void) 22 | { 23 | } 24 | 25 | //------------------------------------------------------------------------ 26 | void uart_putc(uint8_t c) { 27 | while((GET32(BCM283X_AUX_MU_LSR_REG) & 0x20) == 0); 28 | PUT32(BCM283X_AUX_MU_IO_REG,c); 29 | } 30 | 31 | //------------------------------------------------------------------------ 32 | uint8_t uart_getc(void) { 33 | while((GET32(BCM283X_AUX_MU_LSR_REG) & 0x01) == 0); 34 | return(GET32(BCM283X_AUX_MU_IO_REG)); 35 | } 36 | 37 | //------------------------------------------------------------------------ 38 | void uart_init(void) { 39 | uint32_t ra; 40 | 41 | /* GPIO function set */ 42 | ra = GET32(BCM283X_GPIO_GPFSEL1); 43 | ra &= ~(7<<12); /* GPIO14 */ 44 | ra |= 2<<12 ; /* ALT5 */ 45 | ra &= ~(7<<15); /* GPIO15 */ 46 | ra |= 2<<15 ; /* ALT5 */ 47 | PUT32(BCM283X_GPIO_GPFSEL1, ra); 48 | 49 | /* PullUD disable */ 50 | PUT32(BCM283X_GPIO_GPPUD, 0); 51 | for(ra = 0; ra < 150; ra++) dummy(); 52 | PUT32(BCM283X_GPIO_GPPUDCLK0, (1 << 14) | (1 << 15)); 53 | for(ra = 0; ra < 150; ra++) dummy(); 54 | PUT32(BCM283X_GPIO_GPPUDCLK0, 0); 55 | 56 | PUT32(BCM283X_AUX_ENABLES, 1); /* Enable UART1 */ 57 | PUT32(BCM283X_AUX_MU_IER_REG, 0); /* Disable interrupt */ 58 | PUT32(BCM283X_AUX_MU_CNTL_REG, 0); /* Disable Transmitter and Receiver */ 59 | PUT32(BCM283X_AUX_MU_LCR_REG, 3); /* Works in 8-bit mode */ 60 | PUT32(BCM283X_AUX_MU_MCR_REG, 0); /* Disable RTS */ 61 | PUT32(BCM283X_AUX_MU_IIR_REG, 0xC6); /* Enable FIFO, Clear FIFO */ 62 | PUT32(BCM283X_AUX_MU_BAUD_REG, 270); /* 115200 = system clock 250MHz / (8 * (baud + 1)), baud = 270 */ 63 | PUT32(BCM283X_AUX_MU_CNTL_REG, 3); /* Enable Transmitter and Receiver */ 64 | } 65 | //------------------------------------------------------------------------ 66 | void hexstrings(uint32_t d) { 67 | uint32_t rb; 68 | uint32_t rc; 69 | 70 | rb = 32; 71 | while(1) { 72 | rb -= 4; 73 | rc = (d >> rb) & 0xF; 74 | if(rc > 9) rc += 0x37; else rc += 0x30; 75 | uart_putc(rc); 76 | if(rb == 0) break; 77 | } 78 | uart_putc(0x20); 79 | } 80 | 81 | //------------------------------------------------------------------------ 82 | void hexstring(uint32_t d) { 83 | hexstrings(d); 84 | uart_putc(0x0D); 85 | uart_putc(0x0A); 86 | } 87 | 88 | //------------------------------------------------------------------------ 89 | void decstrings(uint32_t d) { 90 | uint32_t ra; 91 | uint32_t rb; 92 | uint32_t rc; 93 | 94 | ra = 0; 95 | rb = 1000000000; 96 | while(1) { 97 | rc = azo_uint32_div(d, rb); 98 | if(rc == 0 && ra == 1) { 99 | uart_putc('0'); 100 | } else if(rc > 0) { 101 | uart_putc('0' + rc); 102 | ra = 1; 103 | } 104 | if(rb == 1) { 105 | if(ra == 0) { 106 | uart_putc('0'); 107 | } 108 | break; 109 | } 110 | d -= rc * rb; 111 | rb = azo_uint32_div(rb, 10); 112 | } 113 | uart_putc(0x20); 114 | } 115 | 116 | //------------------------------------------------------------------------ 117 | void decstring(uint32_t d) { 118 | decstrings(d); 119 | uart_putc(0x0D); 120 | uart_putc(0x0A); 121 | } 122 | 123 | //------------------------------------------------------------------------ 124 | int notmain(unsigned int earlypc) { 125 | uint32_t pretime, nowtime, msec; 126 | uint32_t clock; 127 | 128 | uart_init(); 129 | 130 | hexstring(0x12345678); 131 | 132 | pretime = 0xFFFFFFFF; 133 | while(1) { 134 | nowtime = GET32(BCM283X_STIMER_CLO); 135 | msec = azo_uint32_mod(nowtime, 1000000); 136 | if(msec == 0 && nowtime != pretime) { 137 | clock = bcm283x_get_cpuclock_med(0); 138 | decstring(clock); 139 | pretime = nowtime; 140 | } 141 | } 142 | 143 | return(0); 144 | } 145 | 146 | //------------------------------------------------------------------------- 147 | 148 | -------------------------------------------------------------------------------- /rp_exclusive/rp_exclusive.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | Copyright (c) 2016 AZO typesylph@gmail.com 3 | referred to David Welch https://github.com/dwelch67 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 14 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 15 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------*/ 17 | 18 | #include "rp_baremetal.h" 19 | 20 | extern void core0stop(void); 21 | extern void core1stop(void); 22 | extern void core2stop(void); 23 | extern void core3stop(void); 24 | 25 | //------------------------------------------------------------------------- 26 | void c_irq_handler(void) 27 | { 28 | } 29 | 30 | //------------------------------------------------------------------------- 31 | static volatile __attribute__ ((aligned (0x4000))) uint32_t page_table[4096]; 32 | static volatile __attribute__ ((aligned (0x20))) uint32_t my_lock; 33 | 34 | volatile unsigned int corestopper0 = 0; 35 | volatile unsigned int corestopper1 = 0; 36 | volatile unsigned int corestopper2 = 0; 37 | volatile unsigned int corestopper3 = 0; 38 | 39 | volatile unsigned int coreready1 = 0; 40 | volatile unsigned int coreready2 = 0; 41 | volatile unsigned int coreready3 = 0; 42 | 43 | //------------------------------------------------------------------------- 44 | void azo_put_char(char c) { 45 | while(1) { 46 | if((GET32(BCM283X_AUX_MU_LSR_REG) & 0x20) != 0) break; 47 | } 48 | PUT32(BCM283X_AUX_MU_IO_REG,c); 49 | } 50 | 51 | //------------------------------------------------------------------------- 52 | void azo_put_str(char* str) { 53 | int i = 0; 54 | while(str[i] != '\0') { 55 | azo_put_char(str[i]); 56 | i++; 57 | } 58 | } 59 | 60 | //------------------------------------------------------------------------- 61 | void azo_put_val(unsigned int i) { 62 | int j; 63 | char str[11]; 64 | char c; 65 | for(j = 0; j < 8; j++) { 66 | c = ((i >> (28 - 4 * j)) & 0xF); 67 | if(c <= 9) { 68 | str[j] = c + '0'; 69 | } else { 70 | str[j] = c + 'A' - 10; 71 | } 72 | } 73 | str[8] = '\r'; 74 | str[9] = '\n'; 75 | str[10] = '\0'; 76 | azo_put_str(str); 77 | } 78 | 79 | //------------------------------------------------------------------------- 80 | void azo_put_addr_val(unsigned int addr) { 81 | azo_put_val(GET32(addr)); 82 | } 83 | 84 | //------------------------------------------------------------------------ 85 | void azo_init_tlb(volatile uint32_t o_pTLB[]) { 86 | uint32_t base = 0; 87 | 88 | /* initialize page_table */ 89 | /* 1008MB(1024MB - 16MB) of kernel memory */ 90 | for(; base < 1008; base++) { 91 | /* 92 | section descriptor (1 MB) 93 | 94 | 31:20 : PA[31:20] Page Address 95 | 19 : NS Non-secure 96 | 18 : 0 97 | 17 : nG Not Global 98 | 16 : S Shareable 99 | 15 : AP[2] Access Permissions 100 | 14:12 : TEX[2:0] Memory region attribute 101 | 11:10 : AP[1:0] Access Permissions 102 | 9 : IMP Implementation defined 103 | 8: 5 : Domain Domain field 104 | 4 : XN Execute-never 105 | 3 : C Memory region attribute 106 | 2 : B Memory region attribute 107 | 1 : 1 108 | 0 : 0 109 | 110 | TEX C B 111 | 000 0 0 : Strongly-ordered, (MemoryType)Strongly-ordered, Shareable 112 | 000 0 1 : Shareable Device, (MT)Device, Shareable 113 | 000 1 0 : Outer and Inner Write-Through, no Write-Allocate, (MT)Normal, S bit 114 | 000 1 1 : Outer and Inner Write-Back, no Write-Allocate, (MT)Normal, S bit 115 | 001 0 0 : Outer and Inner Non-cacheable, (MT)Normal, S bit 116 | 001 0 1 : Reserved 117 | 001 1 x : Outer and Inner Write-Back, Write-Allocate, (MT)Normal, S bit 118 | 010 0 0 : Non-shareable Device, (MT)Device, Non-shareable 119 | 010 0 1 : Reserved 120 | 010 1 x : Reserved 121 | 1BB A A : Cacheability, AA=Inner attribute BB=Outer attribute (MT)Normal, S bit 122 | 123 | Non-secure, outer and inner write back, write allocate, shareable 124 | o_pTLB[base] = (base << 20) | 0x91C0E; 125 | Non-secure, outer and inner write through, no write allocate, shareable 126 | o_pTLB[base] = (base << 20) | 0x90C0A; 127 | Secure, outer and inner write back, write allocate, shareable 128 | o_pTLB[base] = (base << 20) | 0x11C0E; 129 | Secure, outer and inner write through, no write allocate, shareable 130 | o_pTLB[base] = (base << 20) | 0x10C0A; 131 | outer and inner write through, no write allocate, shareable 132 | o_pTLB[base] = (base << 20) | 0x1040A; 133 | */ 134 | // o_pTLB[base] = (base << 20) | 0x01C0A; 135 | /* outer and inner write through, no write allocate, not share */ 136 | o_pTLB[base] = (base << 20) | 0x00C0A; 137 | } 138 | 139 | /* 16MB+1MB peripherals at 0x3F000000 - 0x400FFFFF */ 140 | for(; base < 1025; base++) { 141 | // shared device, never execute 142 | o_pTLB[base] = (base << 20) | 0x10416; 143 | } 144 | 145 | /* unused to 0xFFFFFFFF */ 146 | for(; base < 4096; base++) { 147 | o_pTLB[base] = 0; 148 | } 149 | } 150 | 151 | //------------------------------------------------------------------------ 152 | void uart_init(void) 153 | { 154 | unsigned int ra; 155 | 156 | ra = GET32(BCM283X_GPIO_GPFSEL1); 157 | ra &= ~(7 << 12); /* GPIO14 */ 158 | ra |= 2 << 12 ; /* ALT5 */ 159 | ra &= ~(7 << 15); /* GPIO15 */ 160 | ra |= 2 << 15 ; /* ALT5 */ 161 | PUT32(BCM283X_GPIO_GPFSEL1, ra); 162 | 163 | PUT32(BCM283X_GPIO_GPPUD, 0); 164 | for(ra = 0; ra < 150; ra++) dummy(); 165 | PUT32(BCM283X_GPIO_GPPUDCLK0, (1 << 14) | (1 << 15)); 166 | for(ra = 0; ra < 150; ra++) dummy(); 167 | PUT32(BCM283X_GPIO_GPPUDCLK0, 0); 168 | 169 | PUT32(BCM283X_AUX_ENABLES, 1); /* Enable UART1 */ 170 | PUT32(BCM283X_AUX_MU_IER_REG, 0); /* Disable interrupt */ 171 | PUT32(BCM283X_AUX_MU_CNTL_REG, 0); /* Disable Transmitter and Receiver */ 172 | PUT32(BCM283X_AUX_MU_LCR_REG, 3); /* Works in 8-bit mode */ 173 | PUT32(BCM283X_AUX_MU_MCR_REG, 0); /* Disable RTS */ 174 | PUT32(BCM283X_AUX_MU_IIR_REG, 0xC6); /* Enable FIFO, Clear FIFO */ 175 | PUT32(BCM283X_AUX_MU_BAUD_REG, 270); /* 115200 = system clock 250MHz / (8 * (baud + 1)), baud = 270 */ 176 | PUT32(BCM283X_AUX_MU_CNTL_REG, 3); /* Enable Transmitter and Receiver */ 177 | } 178 | 179 | //------------------------------------------------------------------------ 180 | int notmain(unsigned int earlypc) 181 | { 182 | switch(arm_get_coreid()) { 183 | case 0: 184 | arm_mmu_reset(); 185 | arm_release_lock(&my_lock); 186 | uart_init(); 187 | azo_init_tlb(page_table); 188 | arm_mmu_init((volatile uint32_t*)&page_table); 189 | arm_bp_enable(); 190 | arm_icache_enable(); 191 | arm_dcache_enable(); 192 | 193 | azo_put_val(0x12345678); 194 | 195 | corestopper1 = 0x12345678; 196 | corestopper2 = 0x12345678; 197 | corestopper3 = 0x12345678; 198 | arm_data_memorybarrier(); 199 | core0stop(); 200 | 201 | while(1) { 202 | arm_acquire_lock(&my_lock); 203 | azo_put_char(arm_get_coreid() + '0'); 204 | arm_release_lock(&my_lock); 205 | } 206 | break; 207 | case 1: 208 | core1stop(); 209 | 210 | arm_mmu_reset(); 211 | arm_mmu_init((volatile uint32_t*)&page_table); 212 | arm_bp_enable(); 213 | arm_icache_enable(); 214 | arm_dcache_enable(); 215 | 216 | coreready1 = 0x12345678; 217 | arm_data_memorybarrier(); 218 | while((coreready1 != 0x12345678) || (coreready2 != 0x12345678) || (coreready3 != 0x12345678)) { 219 | arm_data_memorybarrier(); 220 | } 221 | corestopper0 = 0x12345678; 222 | arm_data_memorybarrier(); 223 | 224 | while(1) { 225 | arm_acquire_lock(&my_lock); 226 | azo_put_char(arm_get_coreid() + '0'); 227 | arm_release_lock(&my_lock); 228 | } 229 | break; 230 | case 2: 231 | core2stop(); 232 | 233 | arm_mmu_reset(); 234 | arm_mmu_init((volatile uint32_t*)&page_table); 235 | arm_bp_enable(); 236 | arm_icache_enable(); 237 | arm_dcache_enable(); 238 | 239 | coreready2 = 0x12345678; 240 | arm_data_memorybarrier(); 241 | 242 | while(1) { 243 | arm_acquire_lock(&my_lock); 244 | azo_put_char(arm_get_coreid() + '0'); 245 | arm_release_lock(&my_lock); 246 | } 247 | break; 248 | case 3: 249 | core3stop(); 250 | 251 | arm_mmu_reset(); 252 | arm_mmu_init((volatile uint32_t*)&page_table); 253 | arm_bp_enable(); 254 | arm_icache_enable(); 255 | arm_dcache_enable(); 256 | 257 | coreready3 = 0x12345678; 258 | arm_data_memorybarrier(); 259 | 260 | while(1) { 261 | arm_acquire_lock(&my_lock); 262 | azo_put_char(arm_get_coreid() + '0'); 263 | arm_release_lock(&my_lock); 264 | } 265 | break; 266 | } 267 | 268 | while(1); 269 | 270 | return(0); 271 | } 272 | 273 | //------------------------------------------------------------------------- 274 | 275 | -------------------------------------------------------------------------------- /rp_pwm_audio/rp_pwm_audio.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | Copyright (c) 2016 AZO typesylph@gmail.com 3 | referred to David Welch https://github.com/dwelch67 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 14 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 15 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------*/ 17 | 18 | #include "rp_baremetal.h" 19 | 20 | //------------------------------------------------------------------------- 21 | void c_irq_handler(void) 22 | { 23 | } 24 | 25 | //------------------------------------------------------------------------- 26 | typedef struct azo_pcmdata { 27 | uint32_t size; 28 | uint32_t channels; 29 | uint32_t samplerate; 30 | uint32_t bitswidth; 31 | uint32_t loopcount; 32 | uint32_t endless; 33 | void* data; 34 | } azo_pcmdata_t; 35 | 36 | //------------------------------------------------------------------------- 37 | uint16_t azo_sin_1k_48khz16bit[48] = { 38 | 0x0000, 0x10B5, 0x2120, 0x30FB, 0x3FFF, 0x4DEB, 0x5A82, 0x658C, 0x6ED9, 0x7641, 0x7BA3, 0x7EE7, 0x7FFF, 0x7EE7, 0x7BA3, 0x7641, 39 | 0x6ED9, 0x658C, 0x5A82, 0x4DEB, 0x4000, 0x30FB, 0x2120, 0x10B5, 0x0000, 0xEF4B, 0xDEE0, 0xCF05, 0xC001, 0xB215, 0xA57E, 0x9A74, 40 | 0x9127, 0x89BF, 0x845D, 0x8119, 0x8000, 0x8119, 0x845D, 0x89BF, 0x9127, 0x9A74, 0xA57E, 0xB215, 0xC000, 0xCF05, 0xDEE0, 0xEF4B, 41 | }; 42 | 43 | uint8_t azo_sin_1k_96khz24bit[288] = { 44 | 0x00, 0x00, 0x00, 0x21, 0x5F, 0x08, 0x15, 0xB5, 0x10, 0xB8, 0xF8, 0x18, 0xFB, 0x20, 0x21, 45 | 0xED, 0x24, 0x29, 0xC5, 0xFB, 0x30, 0xEA, 0x9C, 0x38, 0xFF, 0xFF, 0x3F, 0xEC, 0x1C, 0x47, 46 | 0xE4, 0xEB, 0x4D, 0x71, 0x65, 0x54, 0x79, 0x82, 0x5A, 0x49, 0x3C, 0x60, 0x9A, 0x8C, 0x65, 47 | 0x98, 0x6D, 0x6A, 0xEB, 0xD9, 0x6E, 0xB9, 0xCC, 0x72, 0xAF, 0x41, 0x76, 0x01, 0x35, 0x79, 48 | 0x75, 0xA3, 0x7B, 0x5F, 0x8A, 0x7D, 0xAA, 0xE7, 0x7E, 0xD7, 0xB9, 0x7F, 0xFF, 0xFF, 0x7F, 49 | 0xD7, 0xB9, 0x7F, 0xAA, 0xE7, 0x7E, 0x5F, 0x8A, 0x7D, 0x75, 0xA3, 0x7B, 0x01, 0x35, 0x79, 50 | 0xAF, 0x41, 0x76, 0xB9, 0xCC, 0x72, 0xEB, 0xD9, 0x6E, 0x98, 0x6D, 0x6A, 0x9A, 0x8C, 0x65, 51 | 0x49, 0x3C, 0x60, 0x79, 0x82, 0x5A, 0x71, 0x65, 0x54, 0xE4, 0xEB, 0x4D, 0xEC, 0x1C, 0x47, 52 | 0x00, 0x00, 0x40, 0xEA, 0x9C, 0x38, 0xC5, 0xFB, 0x30, 0xED, 0x24, 0x29, 0xFB, 0x20, 0x21, 53 | 0xB8, 0xF8, 0x18, 0x15, 0xB5, 0x10, 0x21, 0x5F, 0x08, 0x00, 0x00, 0x00, 0xDF, 0xA0, 0xF7, 54 | 0xEB, 0x4A, 0xEF, 0x48, 0x07, 0xE7, 0x05, 0xDF, 0xDE, 0x13, 0xDB, 0xD6, 0x3B, 0x04, 0xCF, 55 | 0x16, 0x63, 0xC7, 0x01, 0x00, 0xC0, 0x14, 0xE3, 0xB8, 0x1C, 0x14, 0xB2, 0x8F, 0x9A, 0xAB, 56 | 0x87, 0x7D, 0xA5, 0xB7, 0xC3, 0x9F, 0x66, 0x73, 0x9A, 0x68, 0x92, 0x95, 0x15, 0x26, 0x91, 57 | 0x47, 0x33, 0x8D, 0x51, 0xBE, 0x89, 0xFF, 0xCA, 0x86, 0x8B, 0x5C, 0x84, 0xA1, 0x75, 0x82, 58 | 0x56, 0x18, 0x81, 0x29, 0x46, 0x80, 0x00, 0x00, 0x80, 0x29, 0x46, 0x80, 0x56, 0x18, 0x81, 59 | 0xA1, 0x75, 0x82, 0x8B, 0x5C, 0x84, 0xFF, 0xCA, 0x86, 0x51, 0xBE, 0x89, 0x47, 0x33, 0x8D, 60 | 0x15, 0x26, 0x91, 0x68, 0x92, 0x95, 0x66, 0x73, 0x9A, 0xB7, 0xC3, 0x9F, 0x87, 0x7D, 0xA5, 61 | 0x8F, 0x9A, 0xAB, 0x1C, 0x14, 0xB2, 0x14, 0xE3, 0xB8, 0x00, 0x00, 0xC0, 0x16, 0x63, 0xC7, 62 | 0x3B, 0x04, 0xCF, 0x13, 0xDB, 0xD6, 0x05, 0xDF, 0xDE, 0x48, 0x07, 0xE7, 0xEB, 0x4A, 0xEF, 63 | 0xDF, 0xA0, 0xF7, 64 | }; 65 | 66 | uint32_t azo_sin_1k_48khz32bit[48] = { 67 | 0x00000000, 0x10B5150F, 0x2120FB83, 0x30FBC54D, 68 | 0x3FFFFFFF, 0x4DEBE4FE, 0x5A827999, 0x658C9A2D, 69 | 0x6ED9EBA1, 0x7641AF3C, 0x7BA3751D, 0x7EE7AA4B, 70 | 0x7FFFFFFF, 0x7EE7AA4B, 0x7BA3751D, 0x7641AF3C, 71 | 0x6ED9EBA1, 0x658C9A2D, 0x5A827999, 0x4DEBE4FE, 72 | 0x40000000, 0x30FBC54D, 0x2120FB83, 0x10B5150F, 73 | 0x00000000, 0xEF4AEAF1, 0xDEDF047D, 0xCF043AB3, 74 | 0xC0000001, 0xB2141B02, 0xA57D8667, 0x9A7365D3, 75 | 0x9126145F, 0x89BE50C4, 0x845C8AE3, 0x811855B5, 76 | 0x80000000, 0x811855B5, 0x845C8AE3, 0x89BE50C4, 77 | 0x9126145F, 0x9A7365D3, 0xA57D8667, 0xB2141B02, 78 | 0xC0000000, 0xCF043AB3, 0xDEDF047D, 0xEF4AEAF1, 79 | }; 80 | 81 | //------------------------------------------------------------------------ 82 | void pwm_init(const uint32_t samplerate) { 83 | uint32_t value; 84 | 85 | if(samplerate == 0) { 86 | return; 87 | } 88 | 89 | /* GPIO setting */ 90 | #ifdef AZO_BOARD_RPZERO 91 | value = GET32(BCM283X_GPIO_GPFSEL1); 92 | value &= ~(7 << 6); /* GPIO12 */ 93 | value |= 4 << 6 ; /* ALT0 */ 94 | value &= ~(7 << 9); /* GPIO13 */ 95 | value |= 4 << 9 ; /* ALT0 */ 96 | PUT32(BCM283X_GPIO_GPFSEL1, value); 97 | #else 98 | value = GET32(BCM283X_GPIO_GPFSEL4); 99 | value &= ~(7 << 0); /* GPIO40 */ 100 | value |= 4 << 0 ; /* ALT0 */ 101 | value &= ~(7 << 15); /* GPIO45 */ 102 | value |= 4 << 15 ; /* ALT0 */ 103 | PUT32(BCM283X_GPIO_GPFSEL4, value); 104 | #endif /* AZO_BOARD_RPZERO */ 105 | 106 | /* Clock setting 250MHz */ 107 | PUT32(BCM283X_CM_PWMDIV, BCM283X_CM_PASSWORD + 0x2000); /* Div by 2 */ 108 | PUT32(BCM283X_CM_PWMCTL, BCM283X_CM_PASSWORD + 0x16); /* Enable Clock Generator, PLLD */ 109 | 110 | /* PWM init */ 111 | PUT32(BCM283X_PWM_RNG1, azo_uint32_div(250000000, samplerate)); 112 | PUT32(BCM283X_PWM_RNG2, azo_uint32_div(250000000, samplerate)); 113 | PUT32(BCM283X_PWM_CTL, 0x2161); /* Channel 1&2 Enable + Use FIFO, Clear FIFO */ 114 | } 115 | //------------------------------------------------------------------------ 116 | void pwm_play(const azo_pcmdata_t* pcmdata) { 117 | uint32_t loc; 118 | uint32_t nowloopcount; 119 | uint32_t value; 120 | 121 | if(pcmdata->data == 0) { 122 | return; 123 | } 124 | 125 | do { 126 | for(nowloopcount = 0; nowloopcount < pcmdata->loopcount; nowloopcount++) { 127 | for(loc = 0; loc < pcmdata->size; loc += pcmdata->bitswidth / 8 * pcmdata->channels) { 128 | /* FIFO full wait */ 129 | while(GET32(BCM283X_PWM_STA) & 1); 130 | /* FIFO write */ 131 | if(pcmdata->channels == 1) { 132 | switch(pcmdata->bitswidth) { 133 | case 16: 134 | value = ((uint16_t*)(pcmdata->data + loc))[0] >> 3; 135 | PUT32(BCM283X_PWM_FIF1, value); /* Channel 1 */ 136 | /* FIFO full wait */ 137 | while(GET32(BCM283X_PWM_STA) & 1); 138 | PUT32(BCM283X_PWM_FIF1, value); /* Channel 2 */ 139 | break; 140 | case 24: 141 | value = (((uint8_t*)(pcmdata->data + loc))[1] >> 3) | ((uint16_t)(((uint8_t*)(pcmdata->data + loc))[2]) << 5); 142 | PUT32(BCM283X_PWM_FIF1, value); /* Channel 1 */ 143 | /* FIFO full wait */ 144 | while(GET32(BCM283X_PWM_STA) & 1); 145 | PUT32(BCM283X_PWM_FIF1, value); /* Channel 2 */ 146 | break; 147 | case 32: 148 | value = ((uint32_t*)(pcmdata->data + loc))[0] >> 19; 149 | PUT32(BCM283X_PWM_FIF1, value); /* Channel 1 */ 150 | /* FIFO full wait */ 151 | while(GET32(BCM283X_PWM_STA) & 1); 152 | PUT32(BCM283X_PWM_FIF1, value); /* Channel 2 */ 153 | break; 154 | } 155 | } else { 156 | switch(pcmdata->bitswidth) { 157 | case 16: 158 | PUT32(BCM283X_PWM_FIF1, ((uint16_t*)(pcmdata->data + loc))[0] >> 3); /* Channel 1 */ 159 | /* FIFO full wait */ 160 | while(GET32(BCM283X_PWM_STA) & 1); 161 | PUT32(BCM283X_PWM_FIF1, ((uint16_t*)(pcmdata->data + loc))[1] >> 3); /* Channel 2 */ 162 | break; 163 | case 24: 164 | PUT32(BCM283X_PWM_FIF1, (((uint8_t*)(pcmdata->data + loc))[1] >> 3) | ((uint16_t)(((uint8_t*)(pcmdata->data + loc))[2]) << 5)); /* Channel 1 */ 165 | /* FIFO full wait */ 166 | while(GET32(BCM283X_PWM_STA) & 1); 167 | PUT32(BCM283X_PWM_FIF1, (((uint8_t*)(pcmdata->data + loc))[4] >> 3) | ((uint16_t)(((uint8_t*)(pcmdata->data + loc))[5]) << 5)); /* Channel 2 */ 168 | break; 169 | case 32: 170 | PUT32(BCM283X_PWM_FIF1, ((uint32_t*)(pcmdata->data + loc))[0] >> 19); /* Channel 1 */ 171 | /* FIFO full wait */ 172 | while(GET32(BCM283X_PWM_STA) & 1); 173 | PUT32(BCM283X_PWM_FIF1, ((uint32_t*)(pcmdata->data + loc))[1] >> 19); /* Channel 2 */ 174 | break; 175 | } 176 | } 177 | } 178 | } 179 | } while(pcmdata->endless); 180 | } 181 | //------------------------------------------------------------------------ 182 | int notmain(unsigned int earlypc) 183 | { 184 | azo_pcmdata_t pcmdata = { 185 | 96, 186 | 1, 187 | 48000, 188 | 16, 189 | 1, 190 | 1, 191 | azo_sin_1k_48khz16bit 192 | }; 193 | 194 | /* azo_pcmdata_t pcmdata = { 195 | 288, 196 | 1, 197 | 96000, 198 | 24, 199 | 1, 200 | 1, 201 | azo_sin_1k_96khz24bit 202 | }; 203 | */ 204 | /* azo_pcmdata_t pcmdata = { 205 | 192, 206 | 1, 207 | 48000, 208 | 32, 209 | 1, 210 | 1, 211 | azo_sin_1k_48khz32bit 212 | }; 213 | */ 214 | pwm_init(pcmdata.samplerate); 215 | pwm_play(&pcmdata); 216 | 217 | return(0); 218 | } 219 | 220 | //------------------------------------------------------------------------- 221 | 222 | -------------------------------------------------------------------------------- /rp_pwm_audio_dma/rp_pwm_audio_dma.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | Copyright (c) 2016 AZO typesylph@gmail.com 3 | referred to David Welch https://github.com/dwelch67 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 14 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 15 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------*/ 17 | 18 | #include "rp_baremetal.h" 19 | 20 | //------------------------------------------------------------------------- 21 | void c_irq_handler(void) 22 | { 23 | } 24 | 25 | //------------------------------------------------------------------------- 26 | typedef struct azo_pcmdata { 27 | uint32_t size; 28 | uint32_t channels; 29 | uint32_t samplerate; 30 | uint32_t bitswidth; 31 | uint32_t loopcount; 32 | uint32_t endless; 33 | void* data; 34 | } azo_pcmdata_t; 35 | 36 | //------------------------------------------------------------------------- 37 | typedef struct azo_rawpwmdata { 38 | uint32_t size; 39 | uint32_t samplerate; 40 | uint32_t bitswidth; 41 | uint32_t loopcount; 42 | uint32_t endless; 43 | void* data; 44 | } azo_rawpwmdata_t; 45 | 46 | //------------------------------------------------------------------------- 47 | static __attribute__ ((aligned (32))) bcm283x_dma_cb_t dma_cb_data; 48 | 49 | //------------------------------------------------------------------------- 50 | static __attribute__ ((aligned (4))) uint8_t azo_sin_1k_raw[6144]; 51 | 52 | //------------------------------------------------------------------------- 53 | uint16_t azo_sin_1k_48khz16bit[48] = { 54 | 0x0000, 0x10B5, 0x2120, 0x30FB, 0x3FFF, 0x4DEB, 0x5A82, 0x658C, 0x6ED9, 0x7641, 0x7BA3, 0x7EE7, 0x7FFF, 0x7EE7, 0x7BA3, 0x7641, 55 | 0x6ED9, 0x658C, 0x5A82, 0x4DEB, 0x4000, 0x30FB, 0x2120, 0x10B5, 0x0000, 0xEF4B, 0xDEE0, 0xCF05, 0xC001, 0xB215, 0xA57E, 0x9A74, 56 | 0x9127, 0x89BF, 0x845D, 0x8119, 0x8000, 0x8119, 0x845D, 0x89BF, 0x9127, 0x9A74, 0xA57E, 0xB215, 0xC000, 0xCF05, 0xDEE0, 0xEF4B, 57 | }; 58 | 59 | uint8_t azo_sin_1k_96khz24bit[288] = { 60 | 0x00, 0x00, 0x00, 0x21, 0x5F, 0x08, 0x15, 0xB5, 0x10, 0xB8, 0xF8, 0x18, 0xFB, 0x20, 0x21, 61 | 0xED, 0x24, 0x29, 0xC5, 0xFB, 0x30, 0xEA, 0x9C, 0x38, 0xFF, 0xFF, 0x3F, 0xEC, 0x1C, 0x47, 62 | 0xE4, 0xEB, 0x4D, 0x71, 0x65, 0x54, 0x79, 0x82, 0x5A, 0x49, 0x3C, 0x60, 0x9A, 0x8C, 0x65, 63 | 0x98, 0x6D, 0x6A, 0xEB, 0xD9, 0x6E, 0xB9, 0xCC, 0x72, 0xAF, 0x41, 0x76, 0x01, 0x35, 0x79, 64 | 0x75, 0xA3, 0x7B, 0x5F, 0x8A, 0x7D, 0xAA, 0xE7, 0x7E, 0xD7, 0xB9, 0x7F, 0xFF, 0xFF, 0x7F, 65 | 0xD7, 0xB9, 0x7F, 0xAA, 0xE7, 0x7E, 0x5F, 0x8A, 0x7D, 0x75, 0xA3, 0x7B, 0x01, 0x35, 0x79, 66 | 0xAF, 0x41, 0x76, 0xB9, 0xCC, 0x72, 0xEB, 0xD9, 0x6E, 0x98, 0x6D, 0x6A, 0x9A, 0x8C, 0x65, 67 | 0x49, 0x3C, 0x60, 0x79, 0x82, 0x5A, 0x71, 0x65, 0x54, 0xE4, 0xEB, 0x4D, 0xEC, 0x1C, 0x47, 68 | 0x00, 0x00, 0x40, 0xEA, 0x9C, 0x38, 0xC5, 0xFB, 0x30, 0xED, 0x24, 0x29, 0xFB, 0x20, 0x21, 69 | 0xB8, 0xF8, 0x18, 0x15, 0xB5, 0x10, 0x21, 0x5F, 0x08, 0x00, 0x00, 0x00, 0xDF, 0xA0, 0xF7, 70 | 0xEB, 0x4A, 0xEF, 0x48, 0x07, 0xE7, 0x05, 0xDF, 0xDE, 0x13, 0xDB, 0xD6, 0x3B, 0x04, 0xCF, 71 | 0x16, 0x63, 0xC7, 0x01, 0x00, 0xC0, 0x14, 0xE3, 0xB8, 0x1C, 0x14, 0xB2, 0x8F, 0x9A, 0xAB, 72 | 0x87, 0x7D, 0xA5, 0xB7, 0xC3, 0x9F, 0x66, 0x73, 0x9A, 0x68, 0x92, 0x95, 0x15, 0x26, 0x91, 73 | 0x47, 0x33, 0x8D, 0x51, 0xBE, 0x89, 0xFF, 0xCA, 0x86, 0x8B, 0x5C, 0x84, 0xA1, 0x75, 0x82, 74 | 0x56, 0x18, 0x81, 0x29, 0x46, 0x80, 0x00, 0x00, 0x80, 0x29, 0x46, 0x80, 0x56, 0x18, 0x81, 75 | 0xA1, 0x75, 0x82, 0x8B, 0x5C, 0x84, 0xFF, 0xCA, 0x86, 0x51, 0xBE, 0x89, 0x47, 0x33, 0x8D, 76 | 0x15, 0x26, 0x91, 0x68, 0x92, 0x95, 0x66, 0x73, 0x9A, 0xB7, 0xC3, 0x9F, 0x87, 0x7D, 0xA5, 77 | 0x8F, 0x9A, 0xAB, 0x1C, 0x14, 0xB2, 0x14, 0xE3, 0xB8, 0x00, 0x00, 0xC0, 0x16, 0x63, 0xC7, 78 | 0x3B, 0x04, 0xCF, 0x13, 0xDB, 0xD6, 0x05, 0xDF, 0xDE, 0x48, 0x07, 0xE7, 0xEB, 0x4A, 0xEF, 79 | 0xDF, 0xA0, 0xF7, 80 | }; 81 | 82 | uint32_t azo_sin_1k_48khz32bit[48] = { 83 | 0x00000000, 0x10B5150F, 0x2120FB83, 0x30FBC54D, 84 | 0x3FFFFFFF, 0x4DEBE4FE, 0x5A827999, 0x658C9A2D, 85 | 0x6ED9EBA1, 0x7641AF3C, 0x7BA3751D, 0x7EE7AA4B, 86 | 0x7FFFFFFF, 0x7EE7AA4B, 0x7BA3751D, 0x7641AF3C, 87 | 0x6ED9EBA1, 0x658C9A2D, 0x5A827999, 0x4DEBE4FE, 88 | 0x40000000, 0x30FBC54D, 0x2120FB83, 0x10B5150F, 89 | 0x00000000, 0xEF4AEAF1, 0xDEDF047D, 0xCF043AB3, 90 | 0xC0000001, 0xB2141B02, 0xA57D8667, 0x9A7365D3, 91 | 0x9126145F, 0x89BE50C4, 0x845C8AE3, 0x811855B5, 92 | 0x80000000, 0x811855B5, 0x845C8AE3, 0x89BE50C4, 93 | 0x9126145F, 0x9A7365D3, 0xA57D8667, 0xB2141B02, 94 | 0xC0000000, 0xCF043AB3, 0xDEDF047D, 0xEF4AEAF1, 95 | }; 96 | 97 | //------------------------------------------------------------------------ 98 | void pwm_init(const uint32_t samplerate) { 99 | uint32_t value; 100 | 101 | if(samplerate == 0) { 102 | return; 103 | } 104 | 105 | /* GPIO setting */ 106 | #ifdef AZO_BOARD_RPZERO 107 | value = GET32(BCM283X_GPIO_GPFSEL1); 108 | value &= ~(7 << 6); /* GPIO12 */ 109 | value |= 4 << 6 ; /* ALT0 */ 110 | value &= ~(7 << 9); /* GPIO13 */ 111 | value |= 4 << 9 ; /* ALT0 */ 112 | PUT32(BCM283X_GPIO_GPFSEL1, value); 113 | #else 114 | value = GET32(BCM283X_GPIO_GPFSEL4); 115 | value &= ~(7 << 0); /* GPIO40 */ 116 | value |= 4 << 0 ; /* ALT0 */ 117 | value &= ~(7 << 15); /* GPIO45 */ 118 | value |= 4 << 15 ; /* ALT0 */ 119 | PUT32(BCM283X_GPIO_GPFSEL4, value); 120 | #endif /* AZO_BOARD_RPZERO */ 121 | 122 | /* Clock setting 250MHz */ 123 | PUT32(BCM283X_CM_PWMDIV, BCM283X_CM_PASSWORD + 0x2000); /* Div by 2 */ 124 | PUT32(BCM283X_CM_PWMCTL, BCM283X_CM_PASSWORD + 0x16); /* Enable Clock Generator, PLLD */ 125 | 126 | /* PWM init */ 127 | PUT32(BCM283X_PWM_RNG1, azo_uint32_div(250000000, samplerate)); 128 | PUT32(BCM283X_PWM_RNG2, azo_uint32_div(250000000, samplerate)); 129 | PUT32(BCM283X_PWM_CTL, 0x2161); /* Channel 1&2 Enable + Use FIFO, Clear FIFO */ 130 | } 131 | 132 | //------------------------------------------------------------------------ 133 | /* 134 | 16bit 1channel -> 13bit 2channels : x4 size 135 | 16bit 2channel -> 13bit 2channels : x2 size 136 | 24bit 1channel -> 13bit 2channels : 8/3 size 137 | 24bit 2channel -> 13bit 2channels : 4/3 size 138 | 32bit 1channel -> 13bit 2channels : same size 139 | 32bit 2channel -> 13bit 2channels : 1/2 size 140 | */ 141 | void convert_pcmtoraw(azo_rawpwmdata_t* rawdata, const azo_pcmdata_t* pcmdata) { 142 | uint32_t loc, loc2; 143 | 144 | if(pcmdata->data == 0) { 145 | return; 146 | } 147 | if(rawdata->data == 0) { 148 | return; 149 | } 150 | 151 | if(pcmdata->channels == 0) { 152 | return; 153 | } 154 | switch(pcmdata->samplerate) { 155 | case 8000: 156 | case 16000: 157 | case 32000: 158 | case 44100: 159 | case 48000: 160 | case 96000: 161 | case 192000: 162 | case 384000: 163 | case 768000: 164 | break; 165 | default: 166 | return; 167 | } 168 | switch(pcmdata->bitswidth) { 169 | case 16: 170 | case 24: 171 | case 32: 172 | break; 173 | default: 174 | return; 175 | } 176 | 177 | rawdata->samplerate = pcmdata->samplerate; 178 | rawdata->bitswidth = pcmdata->bitswidth; 179 | rawdata->loopcount = pcmdata->loopcount; 180 | rawdata->endless = pcmdata->endless; 181 | if(rawdata->loopcount == 0 && rawdata->endless != 0) { 182 | rawdata->loopcount = 1; 183 | } 184 | 185 | loc2 = 0; 186 | for(loc = 0; loc < pcmdata->size;) { 187 | switch(pcmdata->bitswidth) { 188 | case 16: 189 | if(pcmdata->channels == 1) { 190 | ((uint32_t*)((uint32_t)rawdata->data + loc2))[0] = ((uint32_t*)((uint32_t)rawdata->data + loc2))[1] = ((uint16_t*)((uint32_t)pcmdata->data + loc))[0] >> 3; 191 | loc += 2; 192 | } else { 193 | ((uint32_t*)((uint32_t)rawdata->data + loc2))[0] = ((uint16_t*)((uint32_t)pcmdata->data + loc))[0] >> 3; 194 | ((uint32_t*)((uint32_t)rawdata->data + loc2))[1] = ((uint16_t*)((uint32_t)pcmdata->data + loc))[0] >> 3; 195 | loc += 2 * pcmdata->channels; 196 | } 197 | loc2 += 8; 198 | break; 199 | case 24: 200 | if(pcmdata->channels == 1) { 201 | ((uint32_t*)((uint32_t)rawdata->data + loc2))[0] = ((uint32_t*)((uint32_t)rawdata->data + loc2))[1] = ((uint16_t)(((uint8_t*)((uint32_t)pcmdata->data + loc))[2]) << 5) | ((uint16_t)(((uint8_t*)((uint32_t)pcmdata->data + loc))[1]) >> 3); 202 | loc += 3; 203 | } else { 204 | ((uint32_t*)((uint32_t)rawdata->data + loc2))[0] = ((uint16_t)(((uint8_t*)((uint32_t)pcmdata->data + loc))[2]) << 5) | ((uint16_t)(((uint8_t*)((uint32_t)pcmdata->data + loc))[1]) >> 3); 205 | ((uint32_t*)((uint32_t)rawdata->data + loc2))[1] = ((uint16_t)(((uint8_t*)((uint32_t)pcmdata->data + loc))[5]) << 5) | ((uint16_t)(((uint8_t*)((uint32_t)pcmdata->data + loc))[4]) >> 3); 206 | loc += 3 * pcmdata->channels; 207 | } 208 | loc2 += 8; 209 | break; 210 | case 32: 211 | if(pcmdata->channels == 1) { 212 | ((uint32_t*)((uint32_t)rawdata->data + loc2))[0] = ((uint32_t*)((uint32_t)rawdata->data + loc2))[1] = ((uint32_t*)((uint32_t)pcmdata->data + loc))[0] >> 19; 213 | loc += 4; 214 | } else { 215 | ((uint32_t*)((uint32_t)rawdata->data + loc2))[0] = ((uint32_t*)((uint32_t)pcmdata->data + loc))[0] >> 19; 216 | ((uint32_t*)((uint32_t)rawdata->data + loc2))[1] = ((uint32_t*)((uint32_t)pcmdata->data + loc))[1] >> 19; 217 | loc += 4 * pcmdata->channels; 218 | } 219 | loc2 += 8; 220 | break; 221 | } 222 | } 223 | 224 | rawdata->size = loc2; 225 | } 226 | 227 | //------------------------------------------------------------------------ 228 | void pwm_raw_play(azo_rawpwmdata_t* rawdata) { 229 | uint32_t nowloopcount; 230 | uint32_t value; 231 | 232 | if(rawdata->data == 0) { 233 | return; 234 | } 235 | 236 | switch(rawdata->samplerate) { 237 | case 8000: 238 | case 16000: 239 | case 32000: 240 | case 44100: 241 | case 48000: 242 | case 96000: 243 | case 192000: 244 | case 384000: 245 | case 768000: 246 | break; 247 | default: 248 | return; 249 | } 250 | switch(rawdata->bitswidth) { 251 | case 16: 252 | case 24: 253 | case 32: 254 | break; 255 | default: 256 | return; 257 | } 258 | if(rawdata->loopcount == 0 && rawdata->endless == 0) { 259 | return; 260 | } 261 | 262 | /* DMA0 enable */ 263 | PUT32(BCM283X_DMA_ENABLE, 0x1); 264 | /* DMA Control Block */ 265 | dma_cb_data.transfer_information = 0x50140; /* Peripheral number 5(PWM), Control Destination Writes with DREQ. Destination address does not change. Source Address Increment 4 */ 266 | dma_cb_data.src_address = (uint32_t)(rawdata->data); 267 | dma_cb_data.dst_address = ARMTOVC_PER_ADDRESS(BCM283X_PWM_FIF1); 268 | dma_cb_data.length = rawdata->size; 269 | dma_cb_data.tdmode_stride = 0; 270 | dma_cb_data.next_control_block_address = 0; 271 | dma_cb_data.reserved1 = 0; 272 | dma_cb_data.reserved2 = 0; 273 | if(rawdata->endless != 0) { 274 | /* loop */ 275 | dma_cb_data.next_control_block_address = (uint32_t)&dma_cb_data; 276 | } 277 | /* DMA set CB */ 278 | PUT32(BCM283X_DMA0_BASE + BCM283X_DMA_CONBLK_AD, (uint32_t)&dma_cb_data); 279 | 280 | /* PWM DMAC Register */ 281 | /* 282 | bit31 : ENAB : DMA Enable 283 | bit 7: 0 : DREQ : DMA Threshold for DREQ signal 284 | */ 285 | value = GET32(BCM283X_PWM_DMAC); 286 | value &= ~(0x800000FF); 287 | value |= 0x80000008 ; /* DMA Enable, DMA Threshold for DREQ signal level 8 */ 288 | PUT32(BCM283X_PWM_DMAC, value); 289 | 290 | if(rawdata->endless == 0) { 291 | for(nowloopcount = 0; nowloopcount < rawdata->loopcount; nowloopcount++) { 292 | /* DMA activate */ 293 | PUT32(BCM283X_DMA0_BASE + BCM283X_DMA_CS, 0x1); 294 | /* wait DMA transfer end */ 295 | while((GET32(BCM283X_DMA0_BASE + BCM283X_DMA_CS) & 0x2) == 0); 296 | /* clear end */ 297 | PUT32(BCM283X_DMA0_BASE + BCM283X_DMA_CS, 0x2); 298 | } 299 | } else { 300 | /* DMA activate */ 301 | PUT32(BCM283X_DMA0_BASE + BCM283X_DMA_CS, 0x1); 302 | } 303 | } 304 | 305 | //------------------------------------------------------------------------ 306 | int notmain(unsigned int earlypc) 307 | { 308 | azo_pcmdata_t pcmdata = { 309 | 96, 310 | 1, 311 | 48000, 312 | 16, 313 | 1, 314 | 1, 315 | azo_sin_1k_48khz16bit 316 | }; 317 | 318 | /* azo_pcmdata_t pcmdata = { 319 | 288, 320 | 1, 321 | 96000, 322 | 24, 323 | 1, 324 | 1, 325 | azo_sin_1k_96khz24bit 326 | }; 327 | */ 328 | /* azo_pcmdata_t pcmdata = { 329 | 192, 330 | 1, 331 | 48000, 332 | 32, 333 | 1, 334 | 1, 335 | azo_sin_1k_48khz32bit 336 | }; 337 | */ 338 | azo_rawpwmdata_t rawdata = { 339 | 0, 340 | 0, 341 | 0, 342 | 0, 343 | 0, 344 | azo_sin_1k_raw 345 | }; 346 | 347 | pwm_init(pcmdata.samplerate); 348 | convert_pcmtoraw(&rawdata, &pcmdata); 349 | pwm_raw_play(&rawdata); 350 | 351 | return(0); 352 | } 353 | 354 | //------------------------------------------------------------------------- 355 | 356 | -------------------------------------------------------------------------------- /rp_pcm_dma_rec/rp_pcm_dma_rec.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | Copyright (c) 2016 AZO typesylph@gmail.com 3 | referred to David Welch https://github.com/dwelch67 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 14 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 15 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------*/ 17 | 18 | #include "rp_baremetal.h" 19 | 20 | #define BUFFERLEN 0x1000000 21 | 22 | //------------------------------------------------------------------------- 23 | void c_irq_handler(void) 24 | { 25 | } 26 | 27 | //------------------------------------------------------------------------- 28 | static __attribute__ ((aligned (32))) bcm283x_dma_cb_t dma_cb_data; 29 | 30 | //------------------------------------------------------------------------- 31 | typedef struct azo_pcmrecinfo { 32 | uint32_t maxsize; 33 | uint32_t channels; 34 | uint32_t samplerate; 35 | uint32_t bitswidth; 36 | void* data; 37 | } azo_pcmrecinfo_t; 38 | 39 | //------------------------------------------------------------------------- 40 | static __attribute__ ((aligned (4))) uint8_t azo_pcmrecdata[BUFFERLEN]; 41 | 42 | //------------------------------------------------------------------------ 43 | void gpclk_init(void) { 44 | uint32_t ra; 45 | 46 | /* GPIO function set */ 47 | ra = GET32(BCM283X_GPIO_GPFSEL0); 48 | ra &= ~(7<<12); /* GPIO4 GPCLK0 */ 49 | ra |= 4<<12 ; /* ALT0 */ 50 | ra &= ~(7<<15); /* GPIO5 GPCLK1 */ 51 | ra |= 4<<15 ; /* ALT0 */ 52 | ra &= ~(7<<18); /* GPIO6 GPCLK2 */ 53 | ra |= 4<<18 ; /* ALT0 */ 54 | PUT32(BCM283X_GPIO_GPFSEL0, ra); 55 | 56 | /* PullUD disable */ 57 | PUT32(BCM283X_GPIO_GPPUD, 0); /* disable pullUD */ 58 | for(ra = 0; ra < 150; ra++) dummy(); /* wait 150 cycles */ 59 | PUT32(BCM283X_GPIO_GPPUDCLK0, (1 << 4) | (1 << 5) | (1 << 6)); /* GPIO4/5/6 pullUD disable */ 60 | for(ra = 0; ra < 150; ra++) dummy(); /* wait 150 cycles */ 61 | PUT32(BCM283X_GPIO_GPPUDCLK0, 0); /* remove the clock */ 62 | } 63 | 64 | //------------------------------------------------------------------------ 65 | void pwm_init(const uint32_t samplerate) { 66 | uint32_t value; 67 | 68 | if(samplerate == 0) { 69 | return; 70 | } 71 | 72 | /* GPIO setting */ 73 | #ifdef AZO_BOARD_RPZERO 74 | value = GET32(BCM283X_GPIO_GPFSEL1); 75 | value &= ~(7 << 6); /* GPIO12 */ 76 | value |= 4 << 6 ; /* ALT0 */ 77 | value &= ~(7 << 9); /* GPIO13 */ 78 | value |= 4 << 9 ; /* ALT0 */ 79 | PUT32(BCM283X_GPIO_GPFSEL1, value); 80 | #else 81 | value = GET32(BCM283X_GPIO_GPFSEL4); 82 | value &= ~(7 << 0); /* GPIO40 */ 83 | value |= 4 << 0 ; /* ALT0 */ 84 | value &= ~(7 << 15); /* GPIO45 */ 85 | value |= 4 << 15 ; /* ALT0 */ 86 | PUT32(BCM283X_GPIO_GPFSEL4, value); 87 | #endif /* AZO_BOARD_RPZERO */ 88 | 89 | /* Clock setting 250MHz */ 90 | PUT32(BCM283X_CM_PWMDIV, BCM283X_CM_PASSWORD + 0x2000); /* Div by 2 */ 91 | PUT32(BCM283X_CM_PWMCTL, BCM283X_CM_PASSWORD + 0x16); /* Enable Clock Generator, PLLD */ 92 | 93 | /* PWM init */ 94 | PUT32(BCM283X_PWM_RNG1, azo_uint32_div(250000000, samplerate)); 95 | PUT32(BCM283X_PWM_RNG2, azo_uint32_div(250000000, samplerate)); 96 | PUT32(BCM283X_PWM_CTL, 0x2161); /* Channel 1&2 Enable + Use FIFO, Clear FIFO */ 97 | } 98 | 99 | //------------------------------------------------------------------------ 100 | void uart_init(void) { 101 | uint32_t ra; 102 | 103 | /* GPIO function set */ 104 | ra = GET32(BCM283X_GPIO_GPFSEL1); 105 | ra &= ~(7<<12); /* GPIO14 */ 106 | ra |= 2<<12 ; /* ALT5 */ 107 | ra &= ~(7<<15); /* GPIO15 */ 108 | ra |= 2<<15 ; /* ALT5 */ 109 | PUT32(BCM283X_GPIO_GPFSEL1, ra); 110 | 111 | /* PullUD disable */ 112 | PUT32(BCM283X_GPIO_GPPUD, 0); 113 | for(ra = 0; ra < 150; ra++) dummy(); 114 | PUT32(BCM283X_GPIO_GPPUDCLK0, (1 << 14) | (1 << 15)); 115 | for(ra = 0; ra < 150; ra++) dummy(); 116 | PUT32(BCM283X_GPIO_GPPUDCLK0, 0); 117 | 118 | PUT32(BCM283X_AUX_ENABLES, 1); /* Enable UART1 */ 119 | PUT32(BCM283X_AUX_MU_IER_REG, 0); /* Disable interrupt */ 120 | PUT32(BCM283X_AUX_MU_CNTL_REG, 0); /* Disable Transmitter and Receiver */ 121 | PUT32(BCM283X_AUX_MU_LCR_REG, 3); /* Works in 8-bit mode */ 122 | PUT32(BCM283X_AUX_MU_MCR_REG, 0); /* Disable RTS */ 123 | PUT32(BCM283X_AUX_MU_IIR_REG, 0xC6); /* Enable FIFO, Clear FIFO */ 124 | PUT32(BCM283X_AUX_MU_BAUD_REG, 270); /* 115200 = system clock 250MHz / (8 * (baud + 1)), baud = 270 */ 125 | PUT32(BCM283X_AUX_MU_CNTL_REG, 3); /* Enable Transmitter and Receiver */ 126 | } 127 | 128 | //------------------------------------------------------------------------ 129 | void uart_putc(uint8_t c) { 130 | while((GET32(BCM283X_AUX_MU_LSR_REG) & 0x20) == 0); 131 | PUT32(BCM283X_AUX_MU_IO_REG,c); 132 | } 133 | 134 | //------------------------------------------------------------------------ 135 | uint8_t uart_getc(void) { 136 | while((GET32(BCM283X_AUX_MU_LSR_REG) & 0x01) == 0); 137 | return(GET32(BCM283X_AUX_MU_IO_REG)); 138 | } 139 | 140 | //------------------------------------------------------------------------ 141 | void puts(const uint8_t* str) { 142 | uint32_t loc = 0; 143 | 144 | while(str[loc] != 0) uart_putc(str[loc++]); 145 | } 146 | 147 | //------------------------------------------------------------------------ 148 | void putsnl(const uint8_t* str) { 149 | puts(str); 150 | uart_putc(0x0D); 151 | uart_putc(0x0A); 152 | } 153 | 154 | //------------------------------------------------------------------------ 155 | void hexstrings(uint32_t d) { 156 | uint32_t rb; 157 | uint32_t rc; 158 | 159 | rb = 32; 160 | while(1) { 161 | rb -= 4; 162 | rc = (d >> rb) & 0xF; 163 | if(rc > 9) rc += 0x37; else rc += 0x30; 164 | uart_putc(rc); 165 | if(rb == 0) break; 166 | } 167 | uart_putc(0x20); 168 | } 169 | 170 | //------------------------------------------------------------------------ 171 | void hexstring(uint32_t d) { 172 | hexstrings(d); 173 | uart_putc(0x0D); 174 | uart_putc(0x0A); 175 | } 176 | 177 | //------------------------------------------------------------------------ 178 | void pcm_rec_init(const uint32_t bitswidth) { 179 | volatile uint32_t value, c; 180 | 181 | switch(bitswidth) { 182 | case 16: 183 | case 24: 184 | case 32: 185 | break; 186 | default: 187 | return; 188 | } 189 | 190 | /* GPIO setting */ 191 | value = GET32(BCM283X_GPIO_GPFSEL1); 192 | value &= ~(7 << 24); /* GPIO18 */ 193 | value |= 4 << 24 ; /* ALT0 PCM_CLK */ 194 | value &= ~(7 << 27); /* GPIO19 */ 195 | value |= 4 << 27 ; /* ALT0 PCM_FS */ 196 | PUT32(BCM283X_GPIO_GPFSEL1, value); 197 | value = GET32(BCM283X_GPIO_GPFSEL2); 198 | value &= ~(7 << 0); /* GPIO20 */ 199 | value |= 4 << 0 ; /* ALT0 PCM_DIN */ 200 | PUT32(BCM283X_GPIO_GPFSEL2, value); 201 | PUT32(BCM283X_GPIO_GPPUD, 0); /* disable pullUD */ 202 | for(c = 0; c < 150; c++) value = GET32(BCM283X_GPIO_GPFSEL1); /* wait 150 cycles */ 203 | PUT32(BCM283X_GPIO_GPPUDCLK0, (1 << 18) | (1 << 19) | (1 << 20)); /* GPIO18/19/20 pullUD disable */ 204 | for(c = 0; c < 150; c++) value = GET32(BCM283X_GPIO_GPFSEL1); /* wait 150 cycles */ 205 | PUT32(BCM283X_GPIO_GPPUDCLK0, 0); /* remove the clock */ 206 | 207 | /* PCM init */ 208 | /* MODE_A Register */ 209 | /* 210 | bit25 FRXP : Receive Frame Packed Mode 211 | 0 = The data from each channel is written into the RX FIFO. 212 | 1 = The data from both RX channels is merged. 213 | bit23 CLKM : PCM Clock Mode 214 | 0 = Master mode. The PCM CLK is an output and drives at the MCLK rate. 215 | 1* = Slave mode. The PCM CLK is an input. 216 | bit22 CLKI : Clock Invert this logically inverts the PCM_CLK signal. 217 | 0 = Outputs change on rising edge of clock, inputs are sampled on falling edge. 218 | 1* = Outputs change on falling edge of clock, inputs are sampled on rising edge. 219 | bit21 FSM : Frame Sync Invert This logically inverts the frame sync signal. 220 | 0 = Master mode. 221 | 1* = Slave mode. 222 | bit20 FSI : Frame Sync Invert This logically inverts the frame sync signal. 223 | 0* = FS is normally low and goes high to indicate frame sync. 224 | 1 = FS is normally high and goes low to indicate frame sync. 225 | bit19:10 FLEN : Frame Length - Sets the frame length to (FLEN+1) clocks. 226 | Used only when FSM == 0. 227 | bit 9: 0 FSLEN : Frame Sync Length - Sets the frame sync length to (FSLEN) clocks. 228 | Used only when FSM == 0. 229 | PCM_FS will remain permanently active if FSLEN >= FLEN. 230 | 0 = frame sync pulse is off. 231 | */ 232 | PUT32(BCM283X_PCM_MODE_A, 0x0E0FC20); /* FRXP=0, CLKM=1, CLKI=1, FSM=1, FLEN=64-1, FSLEN=32 */ 233 | /* RXC_A Register */ 234 | /* 235 | bit31 CH1WEX : Channel 1 Width Extension Bit 236 | This is the MSB of the channel 1 width (CH1WID). It allows widths greater than 24 bits 237 | bit30 CH1EN : Channel 1 Enable 238 | bit29:20 CH1POS : Channel 1 Position 239 | 0 = indicates the first clock of frame. 240 | bit19:16 CH1WID : Channel 1 Width 241 | width of channel 1 in bit clocks. 242 | This field has been extended with the CH1WEX bit giving a total width of (CH1WEX*16)+CH1WID+8. 243 | The Maximum supported width is 32 bits. 244 | 0 = 8 bits wide 245 | bit15 CH2WEX : Channel 2 Width Extension Bit 246 | bit14 CH2EN : Channel 2 Enable 247 | bit13: 4 CH2POS : Channel 2 Position 248 | bit 3: 0 CH2WID : Channel 2 Width 249 | */ 250 | switch(bitswidth) { 251 | case 16: 252 | PUT32(BCM283X_PCM_RXC_A, 0x40184218); /* CH1WEX=0, CH1EN=CH2EN=1, CH1POS=1, CH2POS=33, CH1WID=CH2WID=8 */ 253 | break; 254 | case 24: 255 | PUT32(BCM283X_PCM_RXC_A, 0xC010C210); /* CH1WEX=1, CH1EN=CH2EN=1, CH1POS=1, CH2POS=33, CH1WID=CH2WID=0 */ 256 | break; 257 | case 32: 258 | // PUT32(BCM283X_PCM_RXC_A, 0xC008C208); /* CH1WEX=1, CH1EN=CH2EN=1, CH1POS=0, CH2POS=32, CH1WID=CH2WID=8 */ /* Left-Justified, not I2S */ 259 | PUT32(BCM283X_PCM_RXC_A, 0xC018C218); /* CH1WEX=1, CH1EN=CH2EN=1, CH1POS=1, CH2POS=33, CH1WID=CH2WID=8 */ 260 | break; 261 | } 262 | /* CS_A Register */ 263 | /* 264 | bit24 SYNC : PCM Clock sync helper. 265 | a software synchronisation mechanism to allow the software to detect when 2 PCM clocks have occurred. 266 | bit23 RXSEX : RX Sign Extend 267 | 0* = No sign extension. 268 | 1 = Sign extend the RX data. 269 | bit20 RXD : Indicates that the RX FIFO contains data 270 | 0 = RX FIFO is empty. 271 | 1 = RX FIFO contains at least 1 sample. 272 | bit18 RXR : Indicates that the RX FIFO needs reading 273 | 0 = RX FIFO is less than RXTHR full. 274 | 1 = RX FIFO is RXTHR or more full. 275 | bit14 RXSYNC : RX FIFO Sync 276 | bit 8: 7 RXTHR : Sets the RX FIFO threshold at which point the RXR flag is set 277 | 00 = set when we have a single sample in the RX FIFO 278 | 01* = set when the RX FIFO is at least full 279 | 10 = set when the RX FIFO is at least 280 | 11 = set when the RX FIFO is full 281 | bit 4 RXCLR : Clear the RX FIFO 282 | bit 1 RXON : Enable reception 283 | bit 0 EN : Enable the PCM Audio Interface 284 | */ 285 | // PUT32(BCM283X_PCM_CS_A, 0x1000493); /* SYNC=1, RXSYNC=1, RXTHR=1, RXCLR=1, RXON=1, EN=1 */ 286 | PUT32(BCM283X_PCM_CS_A, 0x493); /* SYNC=0, RXSYNC=1, RXTHR=1, RXCLR=1, RXON=1, EN=1 */ 287 | 288 | /* RXCLR + SYNC and wait */ 289 | while(GET32(BCM283X_PCM_CS_A) & ((1 << 4) | (1 << 24))); 290 | } 291 | 292 | //------------------------------------------------------------------------ 293 | void pcm_rec(azo_pcmrecinfo_t* recdata) { 294 | uint32_t value; 295 | 296 | if(recdata->data == 0) { 297 | return; 298 | } 299 | 300 | switch(recdata->samplerate) { 301 | case 8000: 302 | case 16000: 303 | case 32000: 304 | case 44100: 305 | case 48000: 306 | case 96000: 307 | case 192000: 308 | case 384000: 309 | case 768000: 310 | break; 311 | default: 312 | return; 313 | } 314 | switch(recdata->bitswidth) { 315 | case 16: 316 | case 24: 317 | case 32: 318 | break; 319 | default: 320 | return; 321 | } 322 | 323 | /* DMA0 enable */ 324 | PUT32(BCM283X_DMA_ENABLE, 0x1); 325 | /* DMA Control Block */ 326 | dma_cb_data.transfer_information = 0x30410; /* Peripheral number 3(PCM RX). Control Source Reads with DREQ. Source address does not change. Destination address Address Increment 4. */ 327 | 328 | dma_cb_data.src_address = ARMTOVC_PER_ADDRESS(BCM283X_PCM_FIFO_A); 329 | dma_cb_data.dst_address = (uint32_t)(recdata->data); 330 | dma_cb_data.length = recdata->maxsize; 331 | dma_cb_data.tdmode_stride = 0; 332 | dma_cb_data.next_control_block_address = 0; 333 | dma_cb_data.reserved1 = 0; 334 | dma_cb_data.reserved2 = 0; 335 | /* DMA set CB */ 336 | PUT32(BCM283X_DMA0_BASE + BCM283X_DMA_CONBLK_AD, (uint32_t)&dma_cb_data); 337 | 338 | /* PCM DREQ_A Register */ 339 | /* 340 | bit 6: 0 : RX : RX Request Level 0x0(0) - 0x3F(63) 341 | */ 342 | value = GET32(BCM283X_PCM_DREQ_A); 343 | value &= ~(0x7F); 344 | value |= 0x30 ; /* level 48 */ 345 | PUT32(BCM283X_PCM_DREQ_A, value); 346 | /* PCM Enable DREQ */ 347 | value = GET32(BCM283X_PCM_CS_A); 348 | value |= 0x200; /* DMA DREQ Enable */ 349 | PUT32(BCM283X_PCM_CS_A, value); 350 | 351 | /* DMA activate */ 352 | PUT32(BCM283X_DMA0_BASE + BCM283X_DMA_CS, 0x1); 353 | 354 | /* wait DMA transfer end */ 355 | while((GET32(BCM283X_DMA0_BASE + BCM283X_DMA_CS) & 0x2) == 0); 356 | } 357 | 358 | //------------------------------------------------------------------------ 359 | uint8_t str1[] = "Hit space key to record."; 360 | uint8_t str2[] = "processing..."; 361 | uint8_t str3[] = "Hit space key to playback."; 362 | 363 | //------------------------------------------------------------------------ 364 | int notmain(unsigned int earlypc) 365 | { 366 | uint32_t loc; 367 | 368 | azo_pcmrecinfo_t recdata = { 369 | BUFFERLEN, 370 | 2, 371 | 48000, 372 | 16, 373 | azo_pcmrecdata 374 | }; 375 | 376 | /* azo_pcmrecinfo_t recdata = { 377 | BUFFERLEN, 378 | 2, 379 | 192000, 380 | 24, 381 | azo_pcmrecdata 382 | }; 383 | */ 384 | /* azo_pcmrecinfo_t recdata = { 385 | BUFFERLEN, 386 | 2, 387 | 384000, 388 | 32, 389 | azo_pcmrecdata 390 | }; 391 | */ 392 | /* azo_pcmrecinfo_t recdata = { 393 | BUFFERLEN, 394 | 2, 395 | 768000, 396 | 32, 397 | azo_pcmrecdata 398 | }; 399 | */ 400 | uart_init(); 401 | gpclk_init(); 402 | pwm_init(48000); 403 | 404 | /* GP0CLK 24.576MHz: PLLD 500 MHz / 24.576MHz = 20.345 : I = 20 : F = (0.345 * 4096) = 1413 */ 405 | PUT32(BCM283X_CM_GP0CTL, BCM283X_CM_PASSWORD + 0x26); /* Disable Clock Generator, oscillator */ 406 | PUT32(BCM283X_CM_GP0DIV, BCM283X_CM_PASSWORD + 0x14585); /* Div by I=20:F=1413 */ 407 | PUT32(BCM283X_CM_GP0CTL, BCM283X_CM_PASSWORD + 0x216); /* Enable Clock Generator, 1stage MASH, PLLD */ 408 | 409 | putsnl(str1); 410 | while(uart_getc() != 0x20); 411 | putsnl(str2); 412 | pcm_rec_init(recdata.bitswidth); 413 | pcm_rec(&recdata); 414 | 415 | while(1) { 416 | putsnl(str3); 417 | while(uart_getc() != 0x20); 418 | putsnl(str2); 419 | 420 | for(loc = 0; loc < BUFFERLEN; loc += azo_uint32_div(recdata.samplerate, 48000) * 8) { 421 | /* FIFO full wait */ 422 | while(GET32(BCM283X_PWM_STA) & 1); 423 | /* FIFO write */ 424 | PUT32(BCM283X_PWM_FIF1, ((uint32_t*)(azo_pcmrecdata + loc))[0] >> 19); /* Channel 1 */ 425 | /* FIFO full wait */ 426 | while(GET32(BCM283X_PWM_STA) & 1); 427 | PUT32(BCM283X_PWM_FIF1, ((uint32_t*)(azo_pcmrecdata + loc))[1] >> 19); /* Channel 2 */ 428 | } 429 | } 430 | 431 | return(0); 432 | } 433 | 434 | //------------------------------------------------------------------------- 435 | 436 | -------------------------------------------------------------------------------- /rp_framebuffer_dma1/rp_framebuffer_dma1.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------- 2 | Copyright (c) 2016 AZO typesylph@gmail.com 3 | referred to David Welch https://github.com/dwelch67 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, 7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 13 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 14 | FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 15 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 16 | -------------------------------------------------------------------------*/ 17 | 18 | #include "rp_baremetal.h" 19 | 20 | //------------------------------------------------------------------------- 21 | void c_irq_handler(void) 22 | { 23 | } 24 | 25 | //------------------------------------------------------------------------- 26 | static __attribute__ ((aligned (0x10))) uint32_t armtovc[256]; 27 | static uint32_t my_fb1[1920 * 1080]; 28 | static uint32_t my_fb2[1920 * 1080]; 29 | 30 | //------------------------------------------------------------------------ 31 | static __attribute__ ((aligned (32))) bcm283x_dma_cb_t dma_cb_data; 32 | 33 | //------------------------------------------------------------------------ 34 | void uart_putc(uint8_t c) { 35 | while((GET32(BCM283X_AUX_MU_LSR_REG) & 0x20) == 0); 36 | PUT32(BCM283X_AUX_MU_IO_REG,c); 37 | } 38 | 39 | //------------------------------------------------------------------------ 40 | uint8_t uart_getc(void) { 41 | while((GET32(BCM283X_AUX_MU_LSR_REG) & 0x01) == 0); 42 | return(GET32(BCM283X_AUX_MU_IO_REG)); 43 | } 44 | 45 | //------------------------------------------------------------------------ 46 | void uart_init(void) { 47 | uint32_t ra; 48 | 49 | /* GPIO function set */ 50 | ra = GET32(BCM283X_GPIO_GPFSEL1); 51 | ra &= ~(7<<12); /* GPIO14 */ 52 | ra |= 2<<12 ; /* ALT5 */ 53 | ra &= ~(7<<15); /* GPIO15 */ 54 | ra |= 2<<15 ; /* ALT5 */ 55 | PUT32(BCM283X_GPIO_GPFSEL1, ra); 56 | 57 | /* PullUD disable */ 58 | PUT32(BCM283X_GPIO_GPPUD, 0); 59 | for(ra = 0; ra < 150; ra++) dummy(); 60 | PUT32(BCM283X_GPIO_GPPUDCLK0, (1 << 14) | (1 << 15)); 61 | for(ra = 0; ra < 150; ra++) dummy(); 62 | PUT32(BCM283X_GPIO_GPPUDCLK0, 0); 63 | 64 | PUT32(BCM283X_AUX_ENABLES, 1); /* Enable UART1 */ 65 | PUT32(BCM283X_AUX_MU_IER_REG, 0); /* Disable interrupt */ 66 | PUT32(BCM283X_AUX_MU_CNTL_REG, 0); /* Disable Transmitter and Receiver */ 67 | PUT32(BCM283X_AUX_MU_LCR_REG, 3); /* Works in 8-bit mode */ 68 | PUT32(BCM283X_AUX_MU_MCR_REG, 0); /* Disable RTS */ 69 | PUT32(BCM283X_AUX_MU_IIR_REG, 0xC6); /* Enable FIFO, Clear FIFO */ 70 | PUT32(BCM283X_AUX_MU_BAUD_REG, 270); /* 115200 = system clock 250MHz / (8 * (baud + 1)), baud = 270 */ 71 | PUT32(BCM283X_AUX_MU_CNTL_REG, 3); /* Enable Transmitter and Receiver */ 72 | } 73 | //------------------------------------------------------------------------ 74 | void hexstrings(uint32_t d) { 75 | uint32_t rb; 76 | uint32_t rc; 77 | 78 | rb = 32; 79 | while(1) { 80 | rb -= 4; 81 | rc = (d >> rb) & 0xF; 82 | if(rc > 9) rc += 0x37; else rc += 0x30; 83 | uart_putc(rc); 84 | if(rb == 0) break; 85 | } 86 | uart_putc(0x20); 87 | } 88 | 89 | //------------------------------------------------------------------------ 90 | void hexstring(uint32_t d) { 91 | hexstrings(d); 92 | uart_putc(0x0D); 93 | uart_putc(0x0A); 94 | } 95 | 96 | //------------------------------------------------------------------------ 97 | void decstrings(uint32_t d) { 98 | uint32_t ra; 99 | uint32_t rb; 100 | uint32_t rc; 101 | 102 | ra = 0; 103 | rb = 1000000000; 104 | while(1) { 105 | rc = azo_uint32_div(d, rb); 106 | if(rc == 0 && ra == 1) { 107 | uart_putc('0'); 108 | } else if(rc > 0) { 109 | uart_putc('0' + rc); 110 | ra = 1; 111 | } 112 | if(rb == 1) { 113 | if(ra == 0) { 114 | uart_putc('0'); 115 | } 116 | break; 117 | } 118 | d -= rc * rb; 119 | rb = azo_uint32_div(rb, 10); 120 | } 121 | uart_putc(0x20); 122 | } 123 | 124 | //------------------------------------------------------------------------ 125 | void decstring(uint32_t d) { 126 | decstrings(d); 127 | uart_putc(0x0D); 128 | uart_putc(0x0A); 129 | } 130 | 131 | //------------------------------------------------------------------------ 132 | void* bcm283x_display_init(bcm283x_display_config_t* config) { 133 | uint32_t locate, i; 134 | uint32_t* fbp; 135 | uint32_t* fb; 136 | 137 | while(1) { 138 | locate = 1; 139 | 140 | armtovc[locate] = 0x00000000; /* Buffer Request/Response Code */ 141 | /* Request Codes: 0x00000000 Process Request Response Codes: 0x80000000 Request Successful, 0x80000001 Partial Response */ 142 | locate++; 143 | 144 | /* Sequence Of Concatenated Tags */ 145 | armtovc[locate] = BCM283X_TAGS_SET_PHYSICAL_DISPLAY; /* Tag Identifier */ 146 | locate++; 147 | armtovc[locate] = 0x00000008; /* Value Buffer Size In Bytes */ 148 | locate++; 149 | armtovc[locate] = 0x00000008; /* 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes */ 150 | locate++; 151 | armtovc[locate] = config->size_x; /* Value Buffer */ 152 | locate++; 153 | armtovc[locate] = config->size_y; /* Value Buffer */ 154 | locate++; 155 | 156 | armtovc[locate] = BCM283X_TAGS_SET_VIRTUAL_BUFFER; /* Tag Identifier */ 157 | locate++; 158 | armtovc[locate] = 0x00000008; /* Value Buffer Size In Bytes */ 159 | locate++; 160 | armtovc[locate] = 0x00000008; /* 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes */ 161 | locate++; 162 | armtovc[locate] = config->size_x; /* Value Buffer */ 163 | locate++; 164 | armtovc[locate] = config->size_y * 2; /* Value Buffer */ 165 | locate++; 166 | 167 | armtovc[locate] = BCM283X_TAGS_SET_DEPTH; /* Tag Identifier */ 168 | locate++; 169 | armtovc[locate] = 0x00000004; /* Value Buffer Size In Bytes */ 170 | locate++; 171 | armtovc[locate] = 0x00000004; /* 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes */ 172 | locate++; 173 | armtovc[locate] = config->depth; /* Value Buffer */ 174 | locate++; 175 | 176 | armtovc[locate] = BCM283X_TAGS_SET_VIRTUAL_OFFSET; /* Tag Identifier */ 177 | locate++; 178 | armtovc[locate] = 0x00000008; /* Value Buffer Size In Bytes */ 179 | locate++; 180 | armtovc[locate] = 0x00000008; /* 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes */ 181 | locate++; 182 | armtovc[locate] = 0; /* Value Buffer */ 183 | locate++; 184 | armtovc[locate] = 0; /* Value Buffer */ 185 | locate++; 186 | 187 | if(config->palette_count != 0 && config->palette != (uint32_t*)0) { 188 | armtovc[locate] = BCM283X_TAGS_SET_PALETTE; /* Tag Identifier */ 189 | locate++; 190 | armtovc[locate] = 0x00000010 + config->palette_count * 4; /* Value Buffer Size In Bytes */ 191 | locate++; 192 | armtovc[locate] = 0x00000010 + config->palette_count * 4; /* 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes */ 193 | locate++; 194 | armtovc[locate] = 0; /* Value Buffer (Offset: First Palette Index To Set (0-255)) */ 195 | locate++; 196 | armtovc[locate] = config->palette_count; /* Value Buffer (Length: Number Of Palette Entries To Set (1-256)) */ 197 | locate++; 198 | for(i = 0; i < config->palette_count; i++) { 199 | armtovc[locate] = config->palette[i]; /* RGBA Palette Values (Offset To Offset+Length-1) */ 200 | locate++; 201 | } 202 | } 203 | 204 | armtovc[locate] = BCM283X_TAGS_ALLOCATE_BUFFER; /* Tag Identifier */ 205 | locate++; 206 | armtovc[locate] = 0x00000008; /* Value Buffer Size In Bytes */ 207 | locate++; 208 | armtovc[locate] = 0x00000008; /* 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes */ 209 | locate++; 210 | fbp = &(armtovc[locate]); /* Frame Buffer point */ 211 | armtovc[locate] = 0; /* Value Buffer */ 212 | locate++; 213 | armtovc[locate] = 0; /* Value Buffer */ 214 | locate++; 215 | 216 | /* End Tag */ 217 | armtovc[locate] = 0; 218 | locate++; 219 | armtovc[locate] = 0; 220 | locate++; 221 | 222 | armtovc[0] = locate * 4; 223 | 224 | /* Mail Box Write */ 225 | PUT32(BCM283X_MAIL_WRITE, (uint32_t)armtovc + BCM283X_MAIL_TAGS); 226 | 227 | while((armtovc[1] & 0x80000000) == 0); 228 | 229 | if(*fbp != 0) break; 230 | } 231 | 232 | while((BCM283X_MAIL_STATUS & BCM283X_MAIL_EMPTY) != 0); 233 | GET32(BCM283X_MAIL_READ); 234 | 235 | fb = (uint32_t*)(*(fbp) & 0x3FFFFFFF); /* Convert Mail Box Frame Buffer Pointer From BUS Address To Physical Address ($CXXXXXXX -> $3XXXXXXX) */ 236 | *fbp = (uint32_t)fb; 237 | 238 | return fb; 239 | } 240 | 241 | //------------------------------------------------------------------------ 242 | void bcm283x_display_setscreenno(const bcm283x_display_config_t* config, uint32_t screen_no) { 243 | uint32_t locate = 1; 244 | 245 | /* Sequence Of Concatenated Tags */ 246 | armtovc[locate] = 0x00000000; 247 | locate++; 248 | 249 | armtovc[locate] = BCM283X_TAGS_SET_VIRTUAL_OFFSET; /* Tag Identifier */ 250 | locate++; 251 | armtovc[locate] = 0x00000008; /* Value Buffer Size In Bytes */ 252 | locate++; 253 | armtovc[locate] = 0x00000008; /* 1 bit (MSB) Request/Response Indicator (0=Request, 1=Response), 31 bits (LSB) Value Length In Bytes */ 254 | locate++; 255 | armtovc[locate] = 0; /* Value Buffer */ 256 | locate++; 257 | armtovc[locate] = config->size_y * screen_no; /* Value Buffer */ 258 | locate++; 259 | 260 | /* End Tag */ 261 | armtovc[locate] = 0; 262 | locate++; 263 | armtovc[locate] = 0; 264 | locate++; 265 | 266 | armtovc[0] = locate * 4; 267 | 268 | /* Mail Box Write */ 269 | while(BCM283X_MAIL_STATUS & BCM283X_MAIL_FULL); 270 | PUT32(BCM283X_MAIL_WRITE, (uint32_t)armtovc + BCM283X_MAIL_TAGS); 271 | while((armtovc[1] & 0x80000000) == 0); 272 | while((BCM283X_MAIL_STATUS & BCM283X_MAIL_EMPTY) != 0); 273 | GET32(BCM283X_MAIL_READ); 274 | } 275 | 276 | //------------------------------------------------------------------------ 277 | void draw05(uint32_t* fb) { 278 | uint32_t x, y; 279 | uint32_t c; 280 | 281 | /* ARIB STD-B28 */ 282 | 283 | /* 40% GRAY */ 284 | for(y = 0; y < 670; y++) { 285 | for(x = 0; x < 240; x++) { 286 | c = BCM283X_DISPLAY_RGBTO32(102,102,102); 287 | fb[(0 + y) * 1920 + (0 + x)] = c; 288 | } 289 | } 290 | /* 75% WHITE */ 291 | for(y = 0; y < 670; y++) { 292 | for(x = 0; x < 206; x++) { 293 | c = BCM283X_DISPLAY_RGBTO32(192,192,192); 294 | fb[(0 + y) * 1920 + (240 + x)] = c; 295 | } 296 | } 297 | /* 75% YELLOW */ 298 | for(y = 0; y < 670; y++) { 299 | for(x = 0; x < 206; x++) { 300 | c = BCM283X_DISPLAY_RGBTO32(192,192,0); 301 | fb[(0 + y) * 1920 + (446 + x)] = c; 302 | } 303 | } 304 | /* 75% CYAN */ 305 | for(y = 0; y < 670; y++) { 306 | for(x = 0; x < 206; x++) { 307 | c = BCM283X_DISPLAY_RGBTO32(0,192,192); 308 | fb[(0 + y) * 1920 + (652 + x)] = c; 309 | } 310 | } 311 | /* 75% GREEN */ 312 | for(y = 0; y < 670; y++) { 313 | for(x = 0; x < 206; x++) { 314 | c = BCM283X_DISPLAY_RGBTO32(0,192,0); 315 | fb[(0 + y) * 1920 + (858 + x)] = c; 316 | } 317 | } 318 | /* 75% MAGENTA */ 319 | for(y = 0; y < 670; y++) { 320 | for(x = 0; x < 206; x++) { 321 | c = BCM283X_DISPLAY_RGBTO32(192,0,192); 322 | fb[(0 + y) * 1920 + (1064 + x)] = c; 323 | } 324 | } 325 | /* 75% RED */ 326 | for(y = 0; y < 670; y++) { 327 | for(x = 0; x < 206; x++) { 328 | c = BCM283X_DISPLAY_RGBTO32(192,0,0); 329 | fb[(0 + y) * 1920 + (1270 + x)] = c; 330 | } 331 | } 332 | /* 75% BLUE */ 333 | for(y = 0; y < 670; y++) { 334 | for(x = 0; x < 204; x++) { 335 | c = BCM283X_DISPLAY_RGBTO32(0,0,192); 336 | fb[(0 + y) * 1920 + (1476 + x)] = c; 337 | } 338 | } 339 | /* 40% GRAY */ 340 | for(y = 0; y < 670; y++) { 341 | for(x = 0; x < 240; x++) { 342 | c = BCM283X_DISPLAY_RGBTO32(102,102,102); 343 | fb[(0 + y) * 1920 + (1680 + x)] = c; 344 | } 345 | } 346 | 347 | /* 100% CYAN */ 348 | for(y = 0; y < 88; y++) { 349 | for(x = 0; x < 240; x++) { 350 | c = BCM283X_DISPLAY_RGBTO32(0,255,255); 351 | fb[(670 + y) * 1920 + (0 + x)] = c; 352 | } 353 | } 354 | /* 100% WHITE */ 355 | for(y = 0; y < 88; y++) { 356 | for(x = 0; x < 206; x++) { 357 | c = BCM283X_DISPLAY_RGBTO32(255,255,255); 358 | fb[(670 + y) * 1920 + (240 + x)] = c; 359 | } 360 | } 361 | /* 75% WHITE */ 362 | for(y = 0; y < 88; y++) { 363 | for(x = 0; x < 1234; x++) { 364 | c = BCM283X_DISPLAY_RGBTO32(192,192,192); 365 | fb[(670 + y) * 1920 + (446 + x)] = c; 366 | } 367 | } 368 | /* 100% BLUE */ 369 | for(y = 0; y < 88; y++) { 370 | for(x = 0; x < 240; x++) { 371 | c = BCM283X_DISPLAY_RGBTO32(0,0,255); 372 | fb[(670 + y) * 1920 + (1680 + x)] = c; 373 | } 374 | } 375 | 376 | /* 100% YELLOW */ 377 | for(y = 0; y < 88; y++) { 378 | for(x = 0; x < 240; x++) { 379 | c = BCM283X_DISPLAY_RGBTO32(255,255,0); 380 | fb[(758 + y) * 1920 + (0 + x)] = c; 381 | } 382 | } 383 | /* Y-RAMP */ 384 | for(y = 0; y < 88; y++) { 385 | for(x = 0; x < 1440; x++) { 386 | c = BCM283X_DISPLAY_RGBTO32(x*178/1440+76,x*178/1440+76,x*178/1440+76); 387 | fb[(758 + y) * 1920 + (240 + x)] = c; 388 | } 389 | } 390 | /* 100% RED */ 391 | for(y = 0; y < 88; y++) { 392 | for(x = 0; x < 240; x++) { 393 | c = BCM283X_DISPLAY_RGBTO32(255,0,0); 394 | fb[(758 + y) * 1920 + (1680 + x)] = c; 395 | } 396 | } 397 | 398 | /* 15% WHITE */ 399 | for(y = 0; y < 234; y++) { 400 | for(x = 0; x < 240; x++) { 401 | c = BCM283X_DISPLAY_RGBTO32(38,38,38); 402 | fb[(846 + y) * 1920 + (0 + x)] = c; 403 | } 404 | } 405 | /* 0% BLACK */ 406 | for(y = 0; y < 234; y++) { 407 | for(x = 0; x < 206; x++) { 408 | c = BCM283X_DISPLAY_RGBTO32(0,0,0); 409 | fb[(846 + y) * 1920 + (240 + x)] = c; 410 | } 411 | } 412 | /* 100% WHITE */ 413 | for(y = 0; y < 234; y++) { 414 | for(x = 0; x < 412; x++) { 415 | c = BCM283X_DISPLAY_RGBTO32(255,255,255); 416 | fb[(846 + y) * 1920 + (446 + x)] = c; 417 | } 418 | } 419 | /* 0% BLACK */ 420 | for(y = 0; y < 234; y++) { 421 | for(x = 0; x < 206; x++) { 422 | c = BCM283X_DISPLAY_RGBTO32(0,0,0); 423 | fb[(846 + y) * 1920 + (858 + x)] = c; 424 | } 425 | } 426 | /* -2%(0%) BLACK */ 427 | for(y = 0; y < 234; y++) { 428 | for(x = 0; x < 82; x++) { 429 | c = BCM283X_DISPLAY_RGBTO32(0,0,0); 430 | fb[(846 + y) * 1920 + (1064 + x)] = c; 431 | } 432 | } 433 | /* 0% BLACK */ 434 | for(y = 0; y < 234; y++) { 435 | for(x = 0; x < 82; x++) { 436 | c = BCM283X_DISPLAY_RGBTO32(0,0,0); 437 | fb[(846 + y) * 1920 + (1146 + x)] = c; 438 | } 439 | } 440 | /* 2% BLACK */ 441 | for(y = 0; y < 234; y++) { 442 | for(x = 0; x < 82; x++) { 443 | c = BCM283X_DISPLAY_RGBTO32(5,5,5); 444 | fb[(846 + y) * 1920 + (1228 + x)] = c; 445 | } 446 | } 447 | /* 0% BLACK */ 448 | for(y = 0; y < 234; y++) { 449 | for(x = 0; x < 82; x++) { 450 | c = BCM283X_DISPLAY_RGBTO32(0,0,0); 451 | fb[(846 + y) * 1920 + (1310 + x)] = c; 452 | } 453 | } 454 | /* 4% BLACK */ 455 | for(y = 0; y < 234; y++) { 456 | for(x = 0; x < 84; x++) { 457 | c = BCM283X_DISPLAY_RGBTO32(10,10,10); 458 | fb[(846 + y) * 1920 + (1392 + x)] = c; 459 | } 460 | } 461 | /* 0% BLACK */ 462 | for(y = 0; y < 234; y++) { 463 | for(x = 0; x < 204; x++) { 464 | c = BCM283X_DISPLAY_RGBTO32(0,0,0); 465 | fb[(846 + y) * 1920 + (1476 + x)] = c; 466 | } 467 | } 468 | /* 15% WHITE */ 469 | for(y = 0; y < 234; y++) { 470 | for(x = 0; x < 240; x++) { 471 | c = BCM283X_DISPLAY_RGBTO32(38,38,38); 472 | fb[(846 + y) * 1920 + (1680 + x)] = c; 473 | } 474 | } 475 | } 476 | 477 | //------------------------------------------------------------------------ 478 | int notmain ( unsigned int earlypc ) 479 | { 480 | uint32_t cx = 0, cy = 0; 481 | int32_t dx, dy; 482 | uint32_t fcount, pretime, currenttime; 483 | uint8_t* fb; 484 | bcm283x_display_config_t config = {1920, 1080, 32, 0, 0, 0, (uint32_t*)0}; 485 | uint32_t screen_no = 0; 486 | 487 | uart_init(); 488 | fb = bcm283x_display_init(&config); 489 | 490 | draw05(my_fb1); 491 | draw05(my_fb2); 492 | 493 | /* DMA0 enable */ 494 | PUT32(BCM283X_DMA_ENABLE, 0x1); 495 | /* DMA Control Block */ 496 | dma_cb_data.transfer_information = 0x332; /* Source Address Increment 32, Destination Address Increment 32, 2D Mode */ 497 | dma_cb_data.length = (1080 << 16) + (1920 * 4); /* 0:15 XLENGTH, 16:29 YLENGTH */ 498 | dma_cb_data.tdmode_stride = 0; 499 | dma_cb_data.next_control_block_address = 0; 500 | dma_cb_data.reserved1 = 0; 501 | dma_cb_data.reserved2 = 0; 502 | 503 | pretime = 0; 504 | fcount = 0; 505 | dx = dy = 32; 506 | while(1) { 507 | currenttime = GET32(BCM283X_STIMER_CLO); 508 | if(pretime != currenttime) { 509 | if(currenttime - pretime >= 1000000) { 510 | /* output fps */ 511 | decstrings(azo_uint32_div(fcount, azo_uint32_div(currenttime - pretime, 1000000))); 512 | uart_putc('f'); 513 | uart_putc('p'); 514 | uart_putc('s'); 515 | uart_putc(0x0D); 516 | uart_putc(0x0A); 517 | 518 | pretime = currenttime; 519 | fcount = 0; 520 | } 521 | } 522 | 523 | /* origin */ 524 | if(cx + dx >= 1920) 525 | cx -= 1920; 526 | if(cy + dy >= 1080) 527 | cy -= 1080; 528 | cx += dx; 529 | cy += dy; 530 | 531 | /* DMA src set */ 532 | dma_cb_data.src_address = (uint32_t)my_fb1 + ((cy * 1920 + cx) << 2); 533 | /* DMA dest set */ 534 | if(screen_no == 0) { 535 | /* write to screen 1 */ 536 | dma_cb_data.dst_address = (uint32_t)fb + 1920*1080*4; 537 | } else { 538 | /* write to screen 0 */ 539 | dma_cb_data.dst_address = (uint32_t)fb; 540 | } 541 | /* DMA set CB */ 542 | PUT32(BCM283X_DMA0_BASE + BCM283X_DMA_CONBLK_AD, (uint32_t)&(dma_cb_data)); 543 | /* DMA activate */ 544 | PUT32(BCM283X_DMA0_BASE + BCM283X_DMA_CS, 0x1); 545 | 546 | /* wait DMA transfer end */ 547 | while((GET32(BCM283X_DMA0_BASE + BCM283X_DMA_CS) & 0x2) == 0); 548 | /* clear end */ 549 | PUT32(BCM283X_DMA0_BASE + BCM283X_DMA_CS, 0x2); 550 | 551 | /* flip screen */ 552 | if(screen_no == 0) { 553 | /* screen 1 */ 554 | bcm283x_display_setscreenno(&config, 1); 555 | screen_no = 1; 556 | } else { 557 | /* screen 0 */ 558 | bcm283x_display_setscreenno(&config, 0); 559 | screen_no = 0; 560 | } 561 | 562 | fcount++; 563 | } 564 | 565 | return(0); 566 | } 567 | 568 | //------------------------------------------------------------------------- 569 | 570 | --------------------------------------------------------------------------------