<div dir="ltr">Can someone please push these patches?<div><br></div><div>Thanks,</div><div>Niteesh</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Feb 16, 2020 at 11:05 PM Alan Cudmore <<a href="mailto:alan.cudmore@gmail.com">alan.cudmore@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Awesome! The Pi Zero W is a bonus too! I think we can run RTEMS on all<br>
models except the Pi 4 now.<br>
<br>
On Sun, Feb 16, 2020 at 12:30 PM G. S. Niteesh <<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a>> wrote:<br>
><br>
> Hii Alan,<br>
><br>
> I tested it on my Raspberry Pi 3 model b v1.2 and it works.<br>
> U-Boot is not required anymore :)<br>
><br>
> Thanks,<br>
> Niteesh.<br>
><br>
> On Sun, Feb 16, 2020 at 10:51 PM Alan Cudmore <<a href="mailto:alan.cudmore@gmail.com" target="_blank">alan.cudmore@gmail.com</a>> wrote:<br>
>><br>
>> I'm definitely using the kernel_address, but letting the firmware<br>
>> decide what image to boot. For me kernel.img is the single core ARM<br>
>> images. kernel7.img is used for the raspberry pi 2 and 3. With these<br>
>> names, I can have both images on the same SD card to test in all of my<br>
>> Pis.<br>
>><br>
>><br>
>> my config.txt:<br>
>> enable_uart=1<br>
>> kernel_address=0x200000<br>
>><br>
>><br>
>> On Sun, Feb 16, 2020 at 11:44 AM Christian Mauderer <<a href="mailto:list@c-mauderer.de" target="_blank">list@c-mauderer.de</a>> wrote:<br>
>> ><br>
>> > On 16/02/2020 17:31, G. S. Niteesh wrote:<br>
>> > > Can you please share your config.txt for Pi3.<br>
>> ><br>
>> > +1<br>
>> ><br>
>> > It's interesting that it seems to work without an adapted config.txt. It<br>
>> > should be at least necessary to define the start address.<br>
>> ><br>
>> > ><br>
>> > > Thanks,<br>
>> > > Niteesh<br>
>> > ><br>
>> > > On Sun, Feb 16, 2020 at 9:58 PM Alan Cudmore <<a href="mailto:alan.cudmore@gmail.com" target="_blank">alan.cudmore@gmail.com</a><br>
>> > > <mailto:<a href="mailto:alan.cudmore@gmail.com" target="_blank">alan.cudmore@gmail.com</a>>> wrote:<br>
>> > ><br>
>> > > I tried running my raspberrypi BSP image that worked on the Pi Zero<br>
>> > > and W, but it did not work on the Pi 3.<br>
>> > ><br>
>> > > I built the raspberrypi2 BSP, used objcopy to copy the binary to my sd<br>
>> > > card as kernel7.img, and it works on my Pi 3 and Pi3 A+ ( without<br>
>> > > ethernet) . Note that my config.txt file does not specify the kernel<br>
>> > > image, so the firmware defaults to kernel.img for the single core<br>
>> > > models and kernel7.img for the 2 and 3.<br>
>> > ><br>
>> > > I probably wont get a chance to try u-boot until later today or<br>
>> > > tomorrow.<br>
>> > ><br>
>> > > But these patches are great for enabling the Pi Zero W and Pi 3 models!<br>
>> > > Thanks,<br>
>> > > Alan<br>
>> > ><br>
>> > > On Sun, Feb 16, 2020 at 10:58 AM G. S. Niteesh <<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a><br>
>> > > <mailto:<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a>>> wrote:<br>
>> > > ><br>
>> > > > On Sun, Feb 16, 2020 at 8:37 PM Alan Cudmore<br>
>> > > <<a href="mailto:alan.cudmore@gmail.com" target="_blank">alan.cudmore@gmail.com</a> <mailto:<a href="mailto:alan.cudmore@gmail.com" target="_blank">alan.cudmore@gmail.com</a>>> wrote:<br>
>> > > >><br>
>> > > >> Hi Niteesh,<br>
>> > > >> I can try this patch on my Pi 3. Which BSP should I use? Is there any<br>
>> > > >> special setup or BSP configuration needed?<br>
>> > > >> Thanks,<br>
>> > > >> Alan<br>
>> > > ><br>
>> > > > Hi Alan,<br>
>> > > > First of all, thank you for taking this initiative.<br>
>> > > > I have tried using the default bootloader in Pi3 to load RTEMS but<br>
>> > > it doesn't work,<br>
>> > > > Can you try it?<br>
>> > > > The currently use U-Boot in 32bit mode as the bootloader.<br>
>> > > > You can use the below instructions to build U-Boot in 32bit mode<br>
>> > > ><br>
>> > > > git clone <a href="https://github.com/u-boot/u-boot.git" rel="noreferrer" target="_blank">https://github.com/u-boot/u-boot.git</a> u-boot<br>
>> > > > cd u-boot<br>
>> > > > git revert 995eab8b5b580b67394312b1621c60a71042cd18<br>
>> > > > make CROSS_COMPILE=arm-linux-gnueabi- rpi_3_32b_defconfig<br>
>> > > > make CROSS_COMPILE=arm-linux-gnueabi-<br>
>> > > ><br>
>> > > > This one uses an old version of U-Boot and I don't know if there is<br>
>> > > > a new way to build in 32bit mode.<br>
>> > > ><br>
>> > > > To build the U-Boot image of RTEMS you can use the below instructions<br>
>> > > ><br>
>> > > > arm-rtems5-objcopy -Obinary hello.exe kernel.img<br>
>> > > > mkimage -A arm -O linux -T kernel -a 0x200000 -e 0x200080 -d<br>
>> > > kernel.img -C none rtems.img<br>
>> > > ><br>
>> > > > To load and run in U-Boot<br>
>> > > ><br>
>> > > > fatload mmc 0 0x200000 rtems.img<br>
>> > > > fatload mmc 0 0x1000 bcm2710-rpi-3-b.dtb<br>
>> > > > bootm 0x200000 - 0x1000<br>
>> > > ><br>
>> > > > And to make your U-Boot build process simpler I have uploaded my<br>
>> > > u-boot.bin<br>
>> > > > to my github, please use it :)<br>
>> > > > <a href="https://github.com/gs-niteesh/rpi3_RTEMS" rel="noreferrer" target="_blank">https://github.com/gs-niteesh/rpi3_RTEMS</a><br>
>> > > ><br>
>> > > > And sorry for the delay, I tested all these instructions again<br>
>> > > before sending them.<br>
>> > > ><br>
>> > > > Thanks<br>
>> > > > Niteesh.<br>
>> > > ><br>
>> > > > On Sun, Feb 16, 2020 at 2:35 AM G. S. Niteesh <<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a><br>
>> > > <mailto:<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a>>> wrote:<br>
>> > > >><br>
>> > > >> ><br>
>> > > >> > Hii,<br>
>> > > >> > This is a reminder message since this patch has been unnoticed<br>
>> > > for a while.<br>
>> > > >> > I have tested it on Raspberry Pi 3 and it works fine. There is<br>
>> > > also another patch<br>
>> > > >> ><br>
>> > > <a href="https://lists.rtems.org/pipermail/devel/2020-February/057194.html" rel="noreferrer" target="_blank">https://lists.rtems.org/pipermail/devel/2020-February/057194.html</a>,<br>
>> > > please<br>
>> > > >> > do have a look at these.<br>
>> > > >> ><br>
>> > > >> > Thank you.<br>
>> > > >> > Niteesh<br>
>> > > >> > On Mon, Feb 10, 2020 at 12:52 AM G S Niteesh <<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a><br>
>> > > <mailto:<a href="mailto:gsnb.gn@gmail.com" target="_blank">gsnb.gn@gmail.com</a>>> wrote:<br>
>> > > >> >><br>
>> > > >> >> This patch adds driver for Mini UART present in Raspberry Pi 3<br>
>> > > >> >> and above, this UART is currently used as the primary UART in<br>
>> > > >> >> these models.<br>
>> > > >> >> The Mini UART is similar to ns16550, this driver is built<br>
>> > > >> >> upon libchip/ns16550.<br>
>> > > >> >> ---<br>
>> > > >> >> bsps/arm/raspberrypi/console/console-config.c | 118<br>
>> > > ++++++++++++++++--<br>
>> > > >> >> bsps/arm/raspberrypi/include/bsp/usart.h | 1 +<br>
>> > > >> >> 2 files changed, 110 insertions(+), 9 deletions(-)<br>
>> > > >> >><br>
>> > > >> >> diff --git a/bsps/arm/raspberrypi/console/console-config.c<br>
>> > > b/bsps/arm/raspberrypi/console/console-config.c<br>
>> > > >> >> index 48c4c6a3ec..62196786dd 100644<br>
>> > > >> >> --- a/bsps/arm/raspberrypi/console/console-config.c<br>
>> > > >> >> +++ b/bsps/arm/raspberrypi/console/console-config.c<br>
>> > > >> >> @@ -24,6 +24,7 @@<br>
>> > > >> >><br>
>> > > >> >> #include <libchip/serial.h><br>
>> > > >> >> #include <libfdt.h><br>
>> > > >> >> +#include <libchip/ns16550.h><br>
>> > > >> >><br>
>> > > >> >> #include <bspopts.h><br>
>> > > >> >> #include <bsp/usart.h><br>
>> > > >> >> @@ -34,35 +35,103 @@<br>
>> > > >> >> #include <bsp/console-termios.h><br>
>> > > >> >> #include <bsp/fdt.h><br>
>> > > >> >> #include <bsp/fatal.h><br>
>> > > >> >> +#include <bsp/gpio.h><br>
>> > > >> >> +#include <bsp/rpi-gpio.h><br>
>> > > >> >><br>
>> > > >> >> -<br>
>> > > >> >> -#define UART0 "/dev/ttyS0"<br>
>> > > >> >> +/**<br>
>> > > >> >> + * UART0 - PL011<br>
>> > > >> >> + * UART1 - Mini UART<br>
>> > > >> >> + */<br>
>> > > >> >> +#define PL011 "/dev/ttyAMA0"<br>
>> > > >> >> +#define MINIUART "/dev/ttyS0"<br>
>> > > >> >> #define FBCONS "/dev/fbcons"<br>
>> > > >> >><br>
>> > > >> >> arm_pl011_context pl011_context;<br>
>> > > >> >> +ns16550_context mini_uart_context;<br>
>> > > >> >><br>
>> > > >> >> rpi_fb_context fb_context;<br>
>> > > >> >><br>
>> > > >> >> -static void output_char_serial(char c)<br>
>> > > >> >> +static void output_char_pl011(char c)<br>
>> > > >> >> {<br>
>> > > >> >> arm_pl011_write_polled(&pl011_context.base, c);<br>
>> > > >> >> }<br>
>> > > >> >><br>
>> > > >> >> +static void output_char_mini_uart(char c)<br>
>> > > >> >> +{<br>
>> > > >> >> + ns16550_polled_putchar(&mini_uart_context.base, c);<br>
>> > > >> >> +}<br>
>> > > >> >> +<br>
>> > > >> >> void output_char_fb(char c)<br>
>> > > >> >> {<br>
>> > > >> >> fbcons_write_polled(&fb_context.base, c);<br>
>> > > >> >> }<br>
>> > > >> >><br>
>> > > >> >> +static uint8_t mini_uart_get_reg(uintptr_t port, uint8_t index)<br>
>> > > >> >> +{<br>
>> > > >> >> + volatile uint32_t *val = (volatile uint32_t *)port + index;<br>
>> > > >> >> + return (uint8_t) *val;<br>
>> > > >> >> +}<br>
>> > > >> >> +<br>
>> > > >> >> +static void mini_uart_set_reg(uintptr_t port, uint8_t index,<br>
>> > > uint8_t val)<br>
>> > > >> >> +{<br>
>> > > >> >> + volatile uint32_t *reg = (volatile uint32_t *)port + index;<br>
>> > > >> >> + *reg = val;<br>
>> > > >> >> +}<br>
>> > > >> >> +<br>
>> > > >> >> static void init_ctx_arm_pl011(<br>
>> > > >> >> const void *fdt,<br>
>> > > >> >> int node<br>
>> > > >> >> )<br>
>> > > >> >> {<br>
>> > > >> >> arm_pl011_context *ctx = &pl011_context;<br>
>> > > >> >> - rtems_termios_device_context_initialize(&ctx->base, "UART");<br>
>> > > >> >> + rtems_termios_device_context_initialize(&ctx->base,<br>
>> > > "PL011UART");<br>
>> > > >> >> ctx->regs = raspberrypi_get_reg_of_node(fdt, node);<br>
>> > > >> >> }<br>
>> > > >> >><br>
>> > > >> >> +static uint32_t calculate_baud_divisor(<br>
>> > > >> >> + ns16550_context *ctx,<br>
>> > > >> >> + uint32_t baud<br>
>> > > >> >> +)<br>
>> > > >> >> +{<br>
>> > > >> >> + uint32_t baudDivisor = (ctx->clock / (8 * baud)) - 1;<br>
>> > > >> >> + return baudDivisor;<br>
>> > > >> >> +}<br>
>> > > >> >> +<br>
>> > > >> >> +static void init_ctx_mini_uart(<br>
>> > > >> >> + const void *fdt,<br>
>> > > >> >> + int node<br>
>> > > >> >> +)<br>
>> > > >> >> +{<br>
>> > > >> >> + const char *status;<br>
>> > > >> >> + int len;<br>
>> > > >> >> + ns16550_context *ctx;<br>
>> > > >> >> +<br>
>> > > >> >> + memset(&mini_uart_context, 0, sizeof(mini_uart_context));<br>
>> > > >> >> + ctx = &mini_uart_context;<br>
>> > > >> >> +<br>
>> > > >> >> + rtems_termios_device_context_initialize(&ctx->base,<br>
>> > > "MiniUART");<br>
>> > > >> >> +<br>
>> > > >> >> + status = fdt_getprop(fdt, node, "status", &len);<br>
>> > > >> >> + if ( status == NULL || strcmp(status, "disabled" ) == 0){<br>
>> > > >> >> + return ;<br>
>> > > >> >> + }<br>
>> > > >> >> +<br>
>> > > >> >> + ctx->port = (uintptr_t) raspberrypi_get_reg_of_node(fdt, node);<br>
>> > > >> >> + ctx->initial_baud = MINI_UART_DEFAULT_BAUD;<br>
>> > > >> >> + ctx->clock = BCM2835_CLOCK_FREQ;<br>
>> > > >> >> + ctx->calculate_baud_divisor = calculate_baud_divisor;<br>
>> > > >> >> + ctx->get_reg = mini_uart_get_reg;<br>
>> > > >> >> + ctx->set_reg = mini_uart_set_reg;<br>
>> > > >> >> +<br>
>> > > >> >> + rtems_gpio_bsp_select_specific_io(0, 14, RPI_ALT_FUNC_5, NULL);<br>
>> > > >> >> + rtems_gpio_bsp_select_specific_io(0, 15, RPI_ALT_FUNC_5, NULL);<br>
>> > > >> >> + rtems_gpio_bsp_set_resistor_mode(0, 14, NO_PULL_RESISTOR);<br>
>> > > >> >> + rtems_gpio_bsp_set_resistor_mode(0, 15, NO_PULL_RESISTOR);<br>
>> > > >> >> +<br>
>> > > >> >> + BCM2835_REG(AUX_ENABLES) |= 0x1;<br>
>> > > >> >> + ns16550_probe(&ctx->base);<br>
>> > > >> >> +}<br>
>> > > >> >> +<br>
>> > > >> >> static void register_fb( void )<br>
>> > > >> >> {<br>
>> > > >> >> if (fbcons_probe(&fb_context.base) == true) {<br>
>> > > >> >> @@ -87,16 +156,28 @@ static void console_select( void )<br>
>> > > >> >> link(FBCONS, CONSOLE_DEVICE_NAME);<br>
>> > > >> >> return ;<br>
>> > > >> >> }<br>
>> > > >> >> + } else if ( strncmp( opt, MINIUART, sizeof(MINIUART) - 1<br>
>> > > ) == 0) {<br>
>> > > >> >> + BSP_output_char = output_char_mini_uart;<br>
>> > > >> >> + link(MINIUART, CONSOLE_DEVICE_NAME);<br>
>> > > >> >> + } else if ( strncmp( opt, PL011, sizeof(PL011) - 1 ) == 0) {<br>
>> > > >> >> + BSP_output_char = output_char_pl011;<br>
>> > > >> >> + link(PL011, CONSOLE_DEVICE_NAME);<br>
>> > > >> >> }<br>
>> > > >> >> + }else {<br>
>> > > >> >> + /**<br>
>> > > >> >> + * If no command line option was given, default to PL011.<br>
>> > > >> >> + */<br>
>> > > >> >> + BSP_output_char = output_char_pl011;<br>
>> > > >> >> + link(PL011, CONSOLE_DEVICE_NAME);<br>
>> > > >> >> }<br>
>> > > >> >> - BSP_output_char = output_char_serial;<br>
>> > > >> >> - link(UART0, CONSOLE_DEVICE_NAME);<br>
>> > > >> >> }<br>
>> > > >> >><br>
>> > > >> >> static void uart_probe(void)<br>
>> > > >> >> {<br>
>> > > >> >> static bool initialized = false;<br>
>> > > >> >> const void *fdt;<br>
>> > > >> >> + const char *console;<br>
>> > > >> >> + int len;<br>
>> > > >> >> int node;<br>
>> > > >> >><br>
>> > > >> >> if ( initialized ) {<br>
>> > > >> >> @@ -104,17 +185,29 @@ static void uart_probe(void)<br>
>> > > >> >> }<br>
>> > > >> >><br>
>> > > >> >> fdt = bsp_fdt_get();<br>
>> > > >> >> - node = fdt_node_offset_by_compatible(fdt, -1,<br>
>> > > "brcm,bcm2835-pl011");<br>
>> > > >> >><br>
>> > > >> >> + node = fdt_node_offset_by_compatible(fdt, -1,<br>
>> > > "brcm,bcm2835-pl011");<br>
>> > > >> >> init_ctx_arm_pl011(fdt, node);<br>
>> > > >> >><br>
>> > > >> >> + node = fdt_node_offset_by_compatible(fdt, -1,<br>
>> > > "brcm,bcm2835-aux-uart");<br>
>> > > >> >> + init_ctx_mini_uart(fdt, node);<br>
>> > > >> >> +<br>
>> > > >> >> + node = fdt_path_offset(fdt, "/aliases");<br>
>> > > >> >> + console = fdt_getprop(fdt, node, "serial0", &len);<br>
>> > > >> >> +<br>
>> > > >> >> + if ( strcmp(console, "/soc/serial@7e215040" ) == 0) {<br>
>> > > >> >> + BSP_output_char = output_char_mini_uart;<br>
>> > > >> >> + }else {<br>
>> > > >> >> + BSP_output_char = output_char_pl011;<br>
>> > > >> >> + }<br>
>> > > >> >> +<br>
>> > > >> >> initialized = true;<br>
>> > > >> >> }<br>
>> > > >> >><br>
>> > > >> >> static void output_char(char c)<br>
>> > > >> >> {<br>
>> > > >> >> uart_probe();<br>
>> > > >> >> - output_char_serial(c);<br>
>> > > >> >> + (*BSP_output_char)(c);<br>
>> > > >> >> }<br>
>> > > >> >><br>
>> > > >> >> rtems_status_code console_initialize(<br>
>> > > >> >> @@ -127,12 +220,19 @@ rtems_status_code console_initialize(<br>
>> > > >> >><br>
>> > > >> >> uart_probe();<br>
>> > > >> >> rtems_termios_device_install(<br>
>> > > >> >> - UART0,<br>
>> > > >> >> + PL011,<br>
>> > > >> >> &arm_pl011_fns,<br>
>> > > >> >> NULL,<br>
>> > > >> >> &pl011_context.base<br>
>> > > >> >> );<br>
>> > > >> >><br>
>> > > >> >> + rtems_termios_device_install(<br>
>> > > >> >> + MINIUART,<br>
>> > > >> >> + &ns16550_handler_polled,<br>
>> > > >> >> + NULL,<br>
>> > > >> >> + &mini_uart_context.base<br>
>> > > >> >> + );<br>
>> > > >> >> +<br>
>> > > >> >> register_fb();<br>
>> > > >> >><br>
>> > > >> >> console_select();<br>
>> > > >> >> diff --git a/bsps/arm/raspberrypi/include/bsp/usart.h<br>
>> > > b/bsps/arm/raspberrypi/include/bsp/usart.h<br>
>> > > >> >> index abbf53626c..6af1844b3c 100644<br>
>> > > >> >> --- a/bsps/arm/raspberrypi/include/bsp/usart.h<br>
>> > > >> >> +++ b/bsps/arm/raspberrypi/include/bsp/usart.h<br>
>> > > >> >> @@ -33,6 +33,7 @@ extern "C" {<br>
>> > > >> >> #endif /* __cplusplus */<br>
>> > > >> >><br>
>> > > >> >> #define PL011_DEFAULT_BAUD 115000<br>
>> > > >> >> +#define MINI_UART_DEFAULT_BAUD 115200<br>
>> > > >> >> #define BCM2835_PL011_BASE (RPI_PERIPHERAL_BASE + 0x201000)<br>
>> > > >> >><br>
>> > > >> >> #ifdef __cplusplus<br>
>> > > >> >> --<br>
>> > > >> >> 2.17.1<br>
>> > > >> >><br>
>> > > >> > _______________________________________________<br>
>> > > >> > devel mailing list<br>
>> > > >> > <a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a> <mailto:<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a>><br>
>> > > >> > <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
>> > ><br>
>> > ><br>
>> > > _______________________________________________<br>
>> > > devel mailing list<br>
>> > > <a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
>> > > <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
>> > ><br>
</blockquote></div>