Giter Club home page Giter Club logo

raspi3-tutorial's People

Contributors

anikcandian avatar bztsrc avatar cinemast avatar firestar4204 avatar jacksonmowry avatar jasonbrave avatar maxdesiatov avatar monsoon235 avatar oscarshiang avatar petemoore avatar sedrubal avatar taiyou-tw avatar xistor avatar zumpchke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raspi3-tutorial's Issues

Cannot find the raspi3 emulation capability in QEMU

I have compiled the aarch64-softmmu target for QEMU however I believe that I haven't found the latest source because I have been unable to find any raspberry pi 3 emulation capability. I got the source from QEMU GitHub. would you please help me and others achieve raspberry pi 3 emulation

0B_readsector timeout waiting for ready to read

I can get 0B_readsector to work in qemu, but I cannot get it to work on a Pi 3 B or a Pi 3 B+. I've tried using the prebuilt kernel8.img as well as building my own kernel8.img. The only files on my SD card are bootcode.bin, start.elf, fixup.dat, and kernel8.img. When the Pi boots, it successfully initializes the SD card, but times out when trying to read from the SD card with the following message:
ERROR: Timeout waiting for ready to read

EMMC Commands

Where did you find the commands for the EMMC. I believe I have written a suitable function to write to the SD card but I don't know the hex values for the commands.

File malloc

Sorry for another malloc question but on line 190 of your fat.c in the readfile tutorial you use s of a way of knowing where to place your file data. How big can s get is there a way of knowing how much to allocate before running the sd_readblock command? Once that is done I guess I can use the dir->size as a way for knowing how much to malloc for the file.

Troubleshooting

Hi,
Thank you for this great code. Unfortunately, I am not able to run any of the examples successfully. Here is what I have tried:

  1. format the sd card as FAT32
  2. copy bootcode.bin and start.elf onto the sd card (got them from the raspberry pi github)
  3. copy kernel8.img from an example which should output to the serial port, right to the sd card
  4. put the sd card into the rpi3
  5. power on

Now, from that moment on, I don't get anything on the serial port (I have a working serial-to-usb dongle, which does work properly).
How can I troubleshoot this?

Thanks in advance!

readfile unable to read boot record

I have localised the bug to the fat_getpartition() function
the whole kernel hangs when the line partitionlba=*((unsigned int*)((unsigned long)&_end+0x1C6));
is reached I have tried a few things to try and fix it however all of it has been unsuccessful.

Static buffers for fat.c

I have mostly gotten static buffers for fat.c however I have been unable to understand the fat_readfile() function because of the fat32 and fat16 selection. I see that you do read from them and therefore their contents it important. I am trying to do this because it messes with my malloc like function which uses the _end marker. Please help me understand that piece of code.

14_raspbootin64 does not work.

Hello!

I'v compiled several examples by clang 8.0. Some examples work fine. But serial kernel loader from exmp14 - don't.

It seems that first kernel do not start at all. I can't see even RBIN64 message on terminal, after powering up my RPI3. But example 12_printf, works just fine.

Just tried original kernel8.img from this git-branch. All the same - on terminal screen is nothing, no RBIN64 message.

Also there is an issue with 09_framebuffer example. Original kernel8.img works, but one compiled with clang 8.0 don't.

Don't work at al:
10_virtualmemory
11_exceptions
13_debugger
14_raspbootin64

Don't work versions compiled by clang, nor original images. My board is PRI3 Model B V1.2

09_framebuffer - Color Channel Mapping

I have compiled and run this tutorial on physical hardware and it works well however Homer is a shade of blue. It turns out the framebuffer maps the red and blue channels differently to how GIMP saves the header file. To have the image display with the correct color mapping it is necessary to swap pixel[0] and pixel [2] in homer.h.

#define HEADER_PIXEL(data,pixel) {
pixel[2] = (((data[0] - 33) << 2) | ((data[1] - 33) >> 4));
pixel[1] = ((((data[1] - 33) & 0xF) << 4) | ((data[2] - 33) >> 2));
pixel[0] = ((((data[2] - 33) & 0x3) << 6) | ((data[3] - 33)));
data += 4;
}

Tutorial 9: Framebuffer works only in qemu

For me the tutorial 9: Framebuffer works only in qemu but the screen is black, when I test it on the real hardware. When I add some Instructions in the for loops, that fill the buffer (e.g. wait_cycles(0);) it works. Is it possible that we have to wait for some kind of ack until we can write the next pixel? Can you provide some more docs about the framebuffer?

Btw.: thanks for this tutorial. It is great ๐Ÿ˜‰

The Current El level in Raspberry Pi 3 is 00000003

I have commented the change of execution levels code and i realized my raspberry pi3 CurrentEl starts at 0000003
Do you think this is the cause for no output
when i try including the chamge of execution levels with the below code i get no output.So could this be the cause?

mov     x2, #0x3c4
    msr     spsr_el2, x2
    adr     x2, 5f
    msr     elr_el2, x2
    eret

Make Fails at Line 851

Hey,
Excited to work with the tutorials but when i run the command make -j4 inside binutil 2.29
Get the following error
make[2]: Leaving directory '/home/brian/binutils-2.29/libiberty'
make[1]: Leaving directory '/home/brian/binutils-2.29'
make: *** [Makefile:851: all] Error 2

Tried in fedora and ubuntu same error.

Getting core number

I have read start.S so many times but I can't seem to be able to run all code on core 1 and not core 0. here is what i am trying.
// read cpu id, stop slave cores
mrs x1, mpidr_el1
and x1, x1, #3 //Produces 0 if the core number is 0
cbz x1, 1f //This line means if x1 == 0 then branch to label 1
mrs x1, mpidr_el1 //Get core number and store it in x1
and x1, x1, #3 //Gets core number
sub x1, x1, #1 //Subtract 1 from the core number produces 0 if core number is 1 I would think
cbz x1, 2f //Jump to label 2 if x1 is == 0

Did you do the Stanford cs140e course?

uart.c clock mailbox request returns error

Hi Zoltan,

while implementing your code in another language, I checked the response of the uart.c init mailbox call, and it returns error 0x80000001: error parsing request buffer (partial response).
I think the field skip setting turbo is missing (reference link here).

I was too lazy too look up what a meaningful value is, but setting it with zero works for me for now:
https://github.com/andre-richter/rust-raspi3-tutorial/blob/master/05_uart0/src/uart.rs#L69-L76

Best Regards,
Andre

Unable to find a usable island

Does anyone know how to resolve this error? ( I'm using Ubuntu 16.04)

After a successful "sudo make install" inside binutils-2.29, then I stared build gcc, and got this error:

./configure <options...>
...
checking for isl 0.15 or later... no
required isl version is 0.15 or later
configure: error: Unable to find a usable isl. See config.log for details.
jchen@ubt-naas ~/joe-git-workspace/raspi3-bare-metal/tool-chain/gcc-7.2.0

Will your raspbootin64 run 32-bit code?

I need a version of raspbootin that will run 32-bit ARMv7 code on the Pi3.
I suspect this is not possible?
I got your raspbootin64 booting and talking to raspbootcom, but it just got stuck in a loop of sending and resending my 32-bit image.
I'm working on a project with lots of 32-bit assembly, so I can't easily compile my stuff to 64-bit...
My understanding is that the original raspbootin won't run on the Pi3... Any other suggestions?
Thanks!

Not showing anything on serial port

The screen is blank when using terminal emulator with Rapberry Pi3. Not sure why this is happening.
Previous Tutorials with UART 0 have worked.But this tutorial for some reason does not print anything to the console,I suppose something to do with start.S.Not Sure.Could you help me with this

Virtual Memory example deeply flawed

The virtual memory example is deeply flawed

First there is no such thing as undocumented TTBR_ENABLE, read again what x is on ttbr0_el1 and ttbr1_el1

Specifically this:
Bits [x-1:0] are res0.x is based on the value of TCR_EL1.T0SZ, the stage of translation, and the memory translation granule size. If bits [x-1:0] are not all zero, this is a misaligned Translation Table Base Address. Its effects are constrained unpredictable, where bits [x-1:0] are treated as if all the bits are zero. The value read back from those bits is the value written.

You are using a 4k granual so bit0 to bit 11 are supposed to be zero, you were supposed to make sure you align the table to 4k to guarantee that.

Your TTBR_ENABLE being set to 1 makes a misaligned Translation Table Base Address.

You set invalid flags in the L1 block table entries

// TTBR0, identity L1
paging[0]=(unsigned long)((unsigned char*)&_end+2*PAGESIZE) | // physical address
PT_PAGE | // it has the "Present" flag, which must be set, and we have area in it mapped by pages
PT_AF | // accessed flag. Without this we're going to have a Data Abort exception
PT_USER | // non-privileged
PT_ISH | // inner shareable
PT_MEM; // normal memory

That is wrong that is a level 2 block descriptor the only bits that should be set are bit 0 & 1 and bit 31 if it is Non Secure.

You start non secured mode EL1 so the correct form is
paging[0]=(unsigned long)((unsigned char*)&_end+2*PAGESIZE) | 0x8000000000000003ul; // physical address

Those other bits you OR on fortunately are ignored as they only go as high as bit11 .. see bottom table here which is L1 description Figure D4-16
https://armv8-ref.codingbelief.com/en/chapter_d4/d43_1_vmsav8-64_translation_table_descriptor_formats.html

You do the same to the TTBR1, identity L1.

There is still more issues I am walking thru, do you want me to send you the fixes or do you want to wade thru it yourself.

If it helps this is what the L2 and L3 tables 1:1 should map like for the Pi3
https://github.com/LdB-ECM/Exchange/blob/master/bzt/memmap.s

If you set __mmu_l2_000000000 to TTBR0 it replaces your table you built .. so like
asm volatile ("msr ttbr0_el1, %0" : : "r" ((uintptr_t)&__mmu_l2_000000000));

Clock Interrupt

Hi,
is there any support for the clock interrupt? I have read somewhere that RPI has 1MHz clock-driven interrupt which would help me greatly since I need quite precise timing for the signal generation using GPIO. So far, using your 07_delays example, timing gets corrupted when approaching microseconds. For example, I need to create a pulse 3.8 microseconds long, for each 31.7 microseconds (horizontal sync VGA signal). Using all three variants of wait (cpu cycle, cpu wait and hw wait) got me very unstable timing.
Best regards,
Milan
P.S. I am working on the GUI Raspbootin64 loader in Java. I will commit to my github repo when finished.

RBIN64

Hi,

When I use "qemu-system-aarch64 -M raspi3 -kernel kernel8.img -serial stdio" to do the emulation, it was stuck in "RBIN64" and the screen of 'QEMU' is black. I expected to see the boot initialization and then login on the terminal that shows on my host terminal. What should I do to achieve that?

handling big memory

Do I need any special code to run this code? In general what I need to handle 'big memory'?

#include <stdlib.h>

int main(void)
{
int size = 50010241024;
int pos = 20010241024;
unsigned char* p = malloc(size);
p[pos] = 0xAA;
unsigned char c = p[pos];

while (1) ;
}

Emulating the file system tutorials

Would you please explain what you mean by saying
qemu-system-aarch64 -M raspi3 -drive file=$(yourimagefile),if=sd,format=raw -serial stdio
for the file system tutorials because I don't understand what you mean by $(yourimagefile)

Writing to sd card

How do you write to the sd card? In sd.c there are no write commands defined so how is this achived?

How to find EOF

Is it possible to read the metadata to find the end of file?

Licence

I would just like to know what you would like me to do with the licence that you have at the top of your files. I have heavily modified most of your code and added my own so I am unsure how to reference your work. Here is my GitHub repo where the code is. Sorry I'm still a high school student and I don't have any experience with code referencing.

sd.c

When you in your code have readblock you say you read a block from the sd card and return the number of bytes read. What is a block in this case? I have written a fat driver but the current interface uses a function that takes (uint32_t sector, uint8_t *buffer, uint32_t sector_count) but I'm not sure how your interface works so I can't yet adapt it. Would you please tell me what you have done?

Black screen - no display

We can't get raspi3 to work on the newest Qemu - just a black screen - nothing seems to display regardless of what kind of FAT32 storage containing boot files I add to this command line:
qemu-system-aarch64 -M raspi3 -m 1G -kernel kernel8.img

some error when building up toolchains

Hello,
I'm studying your tutorial. Thank you^^.
There's some error in building binutils.
Could you give me some help?
I followed your tutorial step by step.
I'm testing them by running Ubuntu 18.04.1 LTS in Virtual Box.

rpi@rpi-VirtualBox:~/binutils-2.30$ make -j4
make[1]: leaving directory '/home/rpi/binutils-2.30'
make[1]: nothing to do for 'all-target'
Configuring in ./etc
Configuring in ./intl
Configuring in ./isl
Configuring in ./libiberty
configure: error: cannot find sources () in .././isl
Makefile:5750: recipe for target 'configure-isl' failed
make[1]: *** [configure-isl] Error 1
make[1]: *** waiting for unended jobs....
configure: creating cache ./config.cache
checking whether make sets $(MAKE)... configure: creating cache ./config.cache
checking for a BSD-compatible install... /usr/bin/install -c
configure: creating cache ./config.cache
checking whether to enable maintainer-specific portions of Makefiles... no
checking for makeinfo... /home/rpi/binutils-2.30/missing makeinfo --split-size=5000000
configure: WARNING:
*** Makeinfo is missing. Info documentation will not be built.
checking for perl... perl
yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether NLS is requested... yes
checking for msgfmt... checking build system type... configure: updating cache ./config.cache
/usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
configure: creating ./config.status
checking for xgettext... x86_64-pc-linux-gnu
checking host system type... /usr/bin/xgettext
x86_64-pc-linux-gnu
checking for x86_64-pc-linux-gnu-ar... ar
checking for x86_64-pc-linux-gnu-ranlib... ranlib
checking whether to install libiberty headers and static library... yes
configure: target_header_dir = libiberty
checking for x86_64-pc-linux-gnu-gcc... gcc
checking for msgmerge... /usr/bin/msgmerge
checking for x86_64-pc-linux-gnu-gcc... gcc
checking for C compiler default output file name... checking for C compiler default output file name... a.out
checking whether the C compiler works... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... yes
checking whether we are cross compiling... no
checking for suffix of executables... config.status: creating Makefile

checking for suffix of object files...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... yes
checking for gcc option to accept ISO C89... none needed
none needed
checking how to run the C preprocessor... checking build system type... x86_64-pc-linux-gnu
checking host system type... gcc -E
x86_64-pc-linux-gnu
checking for x86_64-pc-linux-gnu-ranlib... ranlib
checking for library containing strerror... checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... none required
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
yes
checking for an ANSI C-conforming const... checking for stdlib.h... yes
checking for inline... yes
inline
checking for string.h... checking for sys/types.h... yes
yes
checking for sys/stat.h... checking for memory.h... yes
yes
checking for stdlib.h... checking for strings.h... yes
yes
checking for string.h... checking for inttypes.h... yes
yes
checking for memory.h... checking for stdint.h... yes
yes
checking for strings.h... checking for unistd.h... yes
yes
checking minix/config.h usability... checking for inttypes.h... yes
no
checking minix/config.h presence... checking for stdint.h... no
checking for minix/config.h... no
checking whether it is safe to define EXTENSIONS... yes
checking for unistd.h... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking whether gcc supports -W... yes
checking for off_t... yes
checking whether gcc supports -Wall... yes
checking whether gcc supports -Wwrite-strings... yes
yes
checking for size_t... checking whether gcc supports -Wc++-compat... yes
checking whether gcc supports -Wstrict-prototypes... yes
checking whether gcc supports -Wshadow=local... yes
checking for working alloca.h... yes
checking whether gcc supports -pedantic ... yes
checking whether gcc and cc understand -c and -o together... yes
checking for alloca... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... yes
checking for an ANSI C-conforming const... yes
checking for working mmap... yes
checking for inline... inline
checking whether byte ordering is bigendian... yes
checking whether we are using the GNU C Library 2.1 or newer... yes
checking whether integer division by zero raises SIGFPE... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for sys/file.h... yes
checking for sys/param.h... yes
checking for inttypes.h... yes
checking for limits.h... yes
yes
checking for stdint.h... checking for stdlib.h... (cached) yes
checking for malloc.h... yes
yes
checking for unsigned long long... checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking for strings.h... (cached) yes
checking for sys/time.h... yes
checking for inttypes.h... yes
checking for time.h... yes
checking whether the inttypes.h PRIxNN macros are broken... yes
checking for sys/resource.h... yes
no
checking for ld used by GCC... ld
checking if the linker (ld) is GNU ld... yes
checking for shared library run path origin... checking for sys/stat.h... (cached) yes
checking for sys/mman.h... yes
done
checking for fcntl.h... checking argz.h usability... yes
checking for alloca.h... yes
checking for sys/pstat.h... yes
checking argz.h presence... yes
checking for argz.h... yes
no
checking for sys/sysmp.h... checking limits.h usability... no
checking for sys/sysinfo.h... yes
yes
checking limits.h presence... checking for machine/hal_sysinfo.h... yes
checking for limits.h... yes
no
checking locale.h usability... checking for sys/table.h... no
checking for sys/sysctl.h... yes
yes
checking locale.h presence... checking for sys/systemcfg.h... yes
checking for locale.h... yes
no
checking nl_types.h usability... checking for stdint.h... (cached) yes
checking for stdio_ext.h... yes
yes
checking nl_types.h presence... checking for process.h... yes
checking for nl_types.h... yes
no
checking malloc.h usability... checking for sys/prctl.h... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking malloc.h presence... yes
checking whether time.h and sys/time.h may both be included... yes
checking for malloc.h... yes
checking stddef.h usability... yes
checking whether errno must be declared... yes
checking stddef.h presence... no
checking size of int... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking sys/param.h usability... 4
checking size of long... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking for feof_unlocked... 8
checking size of size_t... yes
checking for fgets_unlocked... yes
8
checking for getc_unlocked... checking for long long... yes
checking for getcwd... yes
checking size of long long... yes
checking for getegid... yes
8
checking for geteuid... checking for a 64-bit type... uint64_t
checking for intptr_t... yes
checking for getgid... yes
checking for getuid... yes
checking for uintptr_t... yes
checking for mempcpy... yes
checking for ssize_t... yes
checking for munmap... yes
checking for putenv... yes
checking for pid_t... yes
checking for setenv... yes
yes
checking for library containing strerror... checking for setlocale... none required
checking for asprintf... yes
checking for stpcpy... yes
checking for atexit... yes
checking for strcasecmp... yes
checking for basename... yes
checking for strdup... yes
checking for bcmp... yes
checking for strtoul... yes
checking for bcopy... yes
checking for tsearch... yes
yes
checking for bsearch... checking for __argz_count... yes
yes
checking for bzero... checking for __argz_stringify... yes
yes
checking for __argz_next... checking for calloc... yes
yes
checking for __fsetlocking... checking for clock... yes
yes
checking for iconv... checking for ffs... yes
checking for iconv declaration... yes
checking for getcwd... install-shextern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for nl_langinfo and CODESET... yes
checking for getpagesize... yes
checking for LC_MESSAGES... yes
yes
checking for bison... no
checking whether NLS is requested... yes
checking whether included gettext is requested... no
checking for GNU gettext in libc... checking for gettimeofday... yes
yes
checking whether to use NLS... yes
checking where the gettext function comes from... libc
checking for aclocal... no
checking for autoconf... no
checking for autoheader... no
checking for index... configure: updating cache ./config.cache
configure: creating ./config.status
yes
checking for insque... yes
checking for memchr... yes
config.status: creating Makefile
checking for memcmp... config.status: creating config.intl
config.status: creating config.h
yes
config.status: executing default-1 commands
checking for memcpy... yes
checking for memmem... yes
checking for memmove... yes
checking for mempcpy... yes
checking for memset... yes
checking for mkstemps... yes
checking for putenv... yes
checking for random... yes
checking for rename... yes
checking for rindex... yes
checking for setenv... yes
checking for snprintf... yes
checking for sigsetmask... yes
checking for stpcpy... yes
checking for stpncpy... yes
checking for strcasecmp... yes
checking for strchr... yes
checking for strdup... yes
checking for strncasecmp... yes
checking for strndup... yes
checking for strnlen... yes
checking for strrchr... yes
checking for strstr... yes
checking for strtod... yes
checking for strtol... yes
checking for strtoul... yes
checking for strtoll... yes
checking for strtoull... yes
checking for strverscmp... yes
checking for tmpnam... yes
checking for vasprintf... yes
checking for vfprintf... yes
checking for vprintf... yes
checking for vsnprintf... yes
checking for vsprintf... yes
checking for waitpid... yes
checking for setproctitle... no
checking whether alloca needs Cray hooks... no
checking stack direction for C alloca... -1
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for _doprnt... no
checking for sys_errlist... yes
checking for sys_nerr... yes
checking for sys_siglist... yes
checking for external symbol _system_configuration... no
checking for __fsetlocking... yes
checking for canonicalize_file_name... yes
checking for dup3... yes
checking for getrlimit... yes
checking for getrusage... yes
checking for getsysinfo... no
checking for gettimeofday... (cached) yes
checking for on_exit... yes
checking for psignal... yes
checking for pstat_getdynamic... no
checking for pstat_getstatic... no
checking for realpath... yes
checking for setrlimit... yes
checking for sbrk... yes
checking for spawnve... no
checking for spawnvpe... no
checking for strerror... yes
checking for strsignal... yes
checking for sysconf... yes
checking for sysctl... yes
checking for sysmp... no
checking for table... no
checking for times... yes
checking for wait3... yes
checking for wait4... yes
checking whether basename is declared... yes
checking whether ffs is declared... yes
checking whether asprintf is declared... yes
checking whether vasprintf is declared... yes
checking whether snprintf is declared... yes
checking whether vsnprintf is declared... yes
checking whether calloc is declared... yes
checking whether getenv is declared... yes
checking whether getopt is declared... yes
checking whether malloc is declared... yes
checking whether realloc is declared... yes
checking whether sbrk is declared... yes
checking whether strtol is declared... yes
checking whether strtoul is declared... yes
checking whether strtoll is declared... yes
checking whether strtoull is declared... yes
checking whether strverscmp is declared... yes
checking whether strnlen is declared... yes
checking whether canonicalize_file_name must be declared... no
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... (cached) yes
checking for working mmap... yes
checking for working strncmp... yes
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
config.status: creating testsuite/Makefile
config.status: creating config.h
config.status: executing default commands
make[1]: leaving directory '/home/rpi/binutils-2.30'
Makefile:850: recipe for target 'all' failed
make: *** [all] Error 2
rpi@rpi-VirtualBox:~/binutils-2.30$

This is the some part related to isl in Makefile.
.PHONY: maybe-maintainer-clean-isl maintainer-clean-isl
maybe-maintainer-clean-isl:
maybe-maintainer-clean-isl: maintainer-clean-isl

maintainer-clean-isl:
@[ -f ./isl/Makefile ] || exit 0;
r=${PWD_COMMAND}; export r;
s=cd $(srcdir); ${PWD_COMMAND}; export s;
$(HOST_EXPORTS)
for flag in $(EXTRA_HOST_FLAGS) V=1; do
eval echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|";
done;
echo "Doing maintainer-clean in isl";
(cd $(HOST_SUBDIR)/isl &&
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}"
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}"
"RANLIB=$${RANLIB}"
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}"
maintainer-clean)
|| exit 1

  1. when compiling gcc, some errors.

rpi@rpi-VirtualBox:~/gcc-8.1.0$ sudo make install-gcc
[sudo] rpi์˜ ์•”ํ˜ธ:
/bin/bash ./mkinstalldirs /usr/local/cross-compiler /usr/local/cross-compiler
make[1]: entering '/home/rpi/gcc-8.1.0/host-x86_64-pc-linux-gnu/fixincludes'
rm -rf /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0/install-tools
/bin/bash ../.././fixincludes/../mkinstalldirs /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0/install-tools
mkdir -p -- /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0/install-tools
/bin/bash ../.././fixincludes/../mkinstalldirs /usr/local/cross-compiler/lib/gcc/aarch64-elf/8.1.0/install-tools/include
/usr/bin/install -c -m 644 ../.././fixincludes/README-fixinc
/usr/local/cross-compiler/lib/gcc/aarch64-elf/8.1.0/install-tools/include/README
/usr/bin/install -c fixinc.sh /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0/install-tools/fixinc.sh
/usr/bin/install -c fixincl /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0/install-tools/fixincl
/usr/bin/install -c mkheaders /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0/install-tools/mkheaders
make[1]: leaving '/home/rpi/gcc-8.1.0/host-x86_64-pc-linux-gnu/fixincludes'
make[1]: entering '/home/rpi/gcc-8.1.0/host-x86_64-pc-linux-gnu/lto-plugin'
make[2]: ๋””๋ ‰ํ„ฐ๋ฆฌ '/home/rpi/gcc-8.1.0/host-x86_64-pc-linux-gnu/lto-plugin' ๋“ค์–ด๊ฐ
/bin/mkdir -p '/usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0'
/bin/bash ./libtool --tag=disable-static --mode=install /usr/bin/install -c liblto_plugin.la '/usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0'
libtool: install: /usr/bin/install -c .libs/liblto_plugin.so.0.0.0 /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0/liblto_plugin.so.0.0.0
libtool: install: (cd /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0 && { ln -s -f liblto_plugin.so.0.0.0 liblto_plugin.so.0 || { rm -f liblto_plugin.so.0 && ln -s liblto_plugin.so.0.0.0 liblto_plugin.so.0; }; })
libtool: install: (cd /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0 && { ln -s -f liblto_plugin.so.0.0.0 liblto_plugin.so || { rm -f liblto_plugin.so && ln -s liblto_plugin.so.0.0.0 liblto_plugin.so; }; })
libtool: install: /usr/bin/install -c .libs/liblto_plugin.lai /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0/liblto_plugin.la
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0

Libraries have been installed in:
/usr/local/cross-compiler/libexec/gcc/aarch64-elf/8.1.0

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:

  • add LIBDIR to the `LD_LIBRARY_PATH' environment variable
    during execution
  • add LIBDIR to the `LD_RUN_PATH' environment variable
    during linking
  • use the `-Wl,-rpath -Wl,LIBDIR' linker flag
  • have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

make[2]: nothing to do for 'install-data-am'
make[2]: leaving '/home/rpi/gcc-8.1.0/host-x86_64-pc-linux-gnu/lto-plugin'
make[1]: leaving '/home/rpi/gcc-8.1.0/host-x86_64-pc-linux-gnu/lto-plugin'
make[1]: entering '/home/rpi/gcc-8.1.0/host-x86_64-pc-linux-gnu/gcc'
make[1]: *** no rules for making target 'install'. stop.
make[1]: leaving '/home/rpi/gcc-8.1.0/host-x86_64-pc-linux-gnu/gcc'
Makefile:4342: recipe for target 'install-gcc' failed
make: *** [install-gcc] Error 2

How to build cross toolchain with crosstool-ng

Just to remind myself and others in the future: the following worked:

  • this repo: 9e5611a
  • ct-ng: ab3c204aee88f08481f1f63825d0e94b082ef84e

On ct-ng menuconfig, set:

  • arch: arm64
  • OS: bare metal

Then build. Tested on tutorial 05.

Emulation of stock raspbian image

Hey!

First off, you are doing amazing work here. These tutorials are pretty amazing.

So, I'd like to be able to emulate the stock raspbian for some testing but I can't seem to get any output.

I've attempted copying out the dtb and kernel from the image and running:

qemu-system-aarch64 -M raspi3 -drive file=2018-04-18-raspbian-stretch-lite.img,if=sd,format=raw

qemu-system-aarch64 -M raspi3 -drive file=2018-04-18-raspbian-stretch-lite.img,if=sd,format=raw -dtb bcm2710-rpi-3-b-plus.dtb -append "root=/dev/mmcblk0p2" -kernel kernal7.img

qemu-system-aarch64 -M raspi3 -sd 2018-04-18-raspbian-stretch-lite.img -dtb bcm2710-rpi-3-b-plus.dtb -append "root=/dev/mmcblk0p2" -kernel rpi_raspbian_kernal7.img

along with several other random attempts. However, nothing I seem to do produces any output either using -nographic, or over vnc.

Any sugguestions?

uart0 - incorect mailbox

Hi again,

I find something new, that not look for me ok, but code work well on qemu.
In 05_uart0/uart.c
When you set message line 54 mbox[4] = 8;
I think it should be 0; Why? In mailbox property interface:
https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
we have tag format:
u32: tag identifier
u32: value buffer size in bytes
u32:
Request codes:
b31 clear: request
b30-b0: reserved
Response codes:
b31 set: response
b30-b0: value length in bytes
u8...: value buffer

In your code it is done in this way:
mbox[2] = MBOX_TAG_SETCLKRATE; // set clock rate
mbox[3] = 12;
mbox[4] = 8;
mbox[5] = 2; // UART clock
mbox[6] = 4000000; // 4Mhz

after tag identifier and buffer size should be 4 bytes with code (u32: without label), that should be 0 (because b30-b0 is reserved).

Additional tag 0x00038002 (Set clock rate) have 3 input argument (clock id, rate and skip setting turbo)

In your code you put correct size (12) but incorect number of arguments (clock id and rate). That mean mbox[0] should be 9*4 and between mbox[6] and mbox[7] should be additional element with skip setting turbo argument (0 or 1).
Of course in qemu we cannot set clock rate and I didn't check it on target, however from "mailbox property interface" it look incorect a bit (but propably still work).

Best regards,
Marcin

Printf malloc

In the printf tutorials you say because you don't have malloc you simply place the string after the code. How much would you need to malloc if you had that ability?

00_crosscompiler fixes

binutils does not use isl, so there's no reason to link it. Yes, the configure script searches for it, but it's not used. binutils and gcc share the same ./configure script.

gcc does not use cloog anymore. And there's no need to specify "--with-isl" as long as the symlink is in the gcc source directory.

Black screen on 09_framebuffer framebuffer tutorial on QEMU v2.12

  • e176e5e
  • use apt-get aarch64-linux-gnu- as in #30 which on my Ubuntu 18.04 is GCC 7.3.0.
  • QEMU v2.12.0 as in #29

Then:

cd 09_framebuffer
make
qemu-system-aarch64 -M raspi3 -kernel kernel8.img -serial stdio

SDL window opens, and the default resolution does change to become larger, but remains black.

I don't see any splash for other tutorials as mentioned on README.

I don't have real hardware to test.

Memory Location Disparity Between Broadcom Datasheet and Tutorial

Im attempting to get a project working with bare metal GPIO so that I have the tightest control possible, however, I am running into issues that I am having a hard time diagnosing because of the differences between documentation.

The BCM2837 is apparently identical to the 36, which is also identical to the 35, however, the 2835 documentation at https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf lists the GPIO as 0x7E200000 while this tutorial lists 0x3F200000 for the GPIO.

Right now I just want to turn any pin on and off for proof of concept so that I can make sure my environment is working but I am having trouble.

My test code.

#define GPSET0 (volatile long *)0x3F20001C //GPIO  Pins 0-31     Pin Output Set 0 32 W
#define GPCLR0 (volatile long *)0x3F200028 //GPIO  Pins 0-31     Pin Output Clear 0 32 W

#define GPFSEL0 (volatile long *)0x3F200000 //GPIO Function Select 0 32 R/W 0-9
#define GPFSEL1 (volatile long *)0x3F200004 //GPIO Function Select 1 32 R/W 10-19
#define GPFSEL2 (volatile long *)0x3F200008 //GPIO Function Select 2 32 R/W 20-29

void main()
{

    //SetGPIOFunc(18, FuncOut);

    *GPFSEL0 = 0X9249249;
    *GPFSEL1 = 0X9249249;
    *GPFSEL2 = 0X9249249;

    while (1)
    {
        *GPSET0 = 0xffffffff;
        *GPCLR0 = 0xffffffff;

    }
}

How does the .bss get cleared?

Does x1 get incremented somehow? I think x1 has the same value throughout the loop so it looks like with every iteration a zero is being written to the same place.

In start.S:

    // clear bss
    ldr     x1, =__bss_start
    ldr     w2, =__bss_size
3:  cbz     w2, 4f
    str     xzr, [x1], #8
    sub     w2, w2, #1
    cbnz    w2, 3b

I'm also curious about the immediate offset in the str instruction. Is it necessary?

udisasm usage suggestion

udisasm is really useful, but it prints addresses in hex and requires addresses in decimal.

The "i" command would be more helpful if it took addresses in hex.

Thanks a bunch for the great tutorial!!

Making Link to Isl

Thanks for the great tutorial!

Here's feedback for building the toolchain:

  1. I had to use "make -j1", instead of "make -j4". Otherwise, it stopped short due to errors.
  2. I had to do "ln -s isl-0.18 isl" before "cd binutils-2.29". Otherwise, the build process fails to find the isl source tree.

Again, thank you for your great work!

multicore - incorrect?

Hi again,

I started analyse another tutorials like Leon de Boer's tutorials. Your code look like all core start at the same entry point that why you check there ID and stop it:
https://github.com/bztsrc/raspi3-tutorial/blob/master/02_multicorec/start.S#L31

In LdB tutorial in smartStart64.S he don't do it. Only core0 start execude this code.
https://github.com/LdB-ECM/Raspberry-Pi/blob/master/Multicore/SmartStart64.S#L40

There is something that I missed or this stopping slave core is incorrect? I read this discussion too:
https://www.raspberrypi.org/forums/viewtopic.php?t=172301

Best regards,
Lazor

isl/options.h No such file or directory

Compiling GCC using the instructions has caused make to error out once it hits line 56 in gcc/graphite.c.

I am entirely certain that binutils is compiled correctly and installed, but GCC will not compile. I've triple checked all commands and instructions.

Use CC variable on Makefiles instead of hardcoded aarch64-elf-gcc

This allows people to just:

sudo apt-get install gcc-aarch64-linux-gnu

which will greatly reduce the barrier of entry and make you more famous.

But first we should factor out all those identical makefiles into one on toplevel /Makefile and symlink into each directory.

Since I am lazy I just did a sed for now for my own use: ************@df31015

find . -name Makefile | xargs sed -i 's/aarch64-elf-/aarch64-linux-gnu-/'

FPU coprocessor

I read the README in the printf tutorials and you said that you had to enable the FPU coprocessor however I didn't actually see a chunk of code in start.s that did this. I wanted the coprocessor online because i'm trying to do bare metal SLAM and I need double types to work. How do you bring the coprocessor online? and as a side note apart from clearing the bss is your start.s acceptable for multi core?

List directory function not listing everything

Is there a reason for the fat_listdirectory() function to not list everything I have been trying to read files with similar names (20 chars or so with a number at the end) is there a way to achieve this? Sorry for another one of my questions :)

0E_initrd

When I run the Makefile in 0E_initrd I get the error make: *** No rule to make target 'ramdisk', needed by 'rd.o'. Stop.What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.