Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with compiled Micropython #246

Open
shivampotdar opened this issue Sep 24, 2020 · 7 comments
Open

Compatibility with compiled Micropython #246

shivampotdar opened this issue Sep 24, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@shivampotdar
Copy link

I see that the prebuilt image in this repository is based on MicroPython v1.12-571 (some intermediate version I guess?)

I tried compiling micropython using GCC cross-compiler on Ubuntu 20.04 (with both buildroot download and gcc9.3 based from debian repositories)
I attempted using the current master branch, v1.13 and v1.12 from the micropython repo.
In all the cases, although I can compile without errors, when I run core_tb, I am not able to issue any inputs in the terminal from the keyboard. This does not happen with the prebuilt image.

I am not sure how exactly shall I debug this. But I would be happy to help and provide more details if neeeded.

Thank you.

@paulusmack
Copy link
Collaborator

This sounds like your image is trying to access the potato UART but core_tb has the 16550-style UART.

@titof49
Copy link

titof49 commented Sep 5, 2021

Hi @paulusmack Paul @antonblanchard , i had the same issue.

I saw that you can set the 16550-style UART.
but from my previous tests it wasn't functionnal.
i'll check it with the latest version of micropython .

@titof49
Copy link

titof49 commented Sep 5, 2021

[Solved]

@paulusmack @antonblanchard @shenki @mikey
to correct the issue, you can change in the makefile :

UART ?= potato

by

UART ?= lpc_serial

after you can rebuild and recreate the link

enjoy again ;->>

below the full modifications:


titof49@pcdev:~/uwatt/micropython/ports/powerpc$ diff Makefile Makefile.old
10c10
< UART ?= lpc_serial
---
> UART ?= potato


image

@antonblanchard
Copy link
Owner

Thanks @titof49! We should update micropython to use the 16550 all the time, and eventually get rid of the potato UART in microwatt.

@antonblanchard antonblanchard added the bug Something isn't working label Sep 25, 2021
@iagocaran
Copy link
Contributor

Instead of changing the makefile, you can compile like this:

make -j$(nproc) UART=lpc_serial

@167rgc911
Copy link

167rgc911 commented Jan 10, 2023

In the latest code this seems to be broken again:

(1) potato (default build of micropython):

rgc:~/i/microwatt$ ./core_tb > debug_log
MicroPython v1.19.1-782-g699477d12 on 2023-01-10; bare-metal with POWERPC
Type "help()" for more information.
>>>
  • micropython seems to output the debug string properly
  • but user is unable to perform any input

(2) UART (lpc_serial in micropython):

rgc:~/i/microwatt$ ./core_tb > debug_log

  • micropython can't even output any debug string

AFAIK lpc_uart_init() is
https://github.com/micropython/micropython/blob/1f371947309c5ea6023b6d9065415697cbc75578/ports/powerpc/uart_lpc_serial.c#L100

using a different base address now (LPC_UART_BASE).
https://github.com/micropython/micropython/blob/1f371947309c5ea6023b6d9065415697cbc75578/ports/powerpc/uart_lpc_serial.c#L39

Edit # 1
It is an issue with micropython. Incorrect register offsets. So modifying uart_lpc_serial.c to something like below works.

diff --git a/ports/powerpc/uart_lpc_serial.c b/ports/powerpc/uart_lpc_serial.c
index 760615041..93a9af55f 100644
--- a/ports/powerpc/uart_lpc_serial.c
+++ b/ports/powerpc/uart_lpc_serial.c
@@ -36,21 +36,20 @@
 #define PROC_FREQ       50000000
 #define UART_FREQ       115200
 #define UART_BASE       0xc0002000
-#define LPC_UART_BASE   0x60300d00103f8
-
-/* Taken from skiboot */
-#define REG_RBR         0
-#define REG_THR         0
-#define REG_DLL         0
-#define REG_IER         1
-#define REG_DLM         1
-#define REG_FCR         2
-#define REG_IIR         2
-#define REG_LCR         3
-#define REG_MCR         4
-#define REG_LSR         5
-#define REG_MSR         6
-#define REG_SCR         7
+#define LPC_UART_BASE   UART_BASE
+
+#define REG_RBR         0x00
+#define REG_THR         0x00
+#define REG_DLL         0x00
+#define REG_IER         0x04
+#define REG_DLM         0x04
+#define REG_FCR         0x08
+#define REG_IIR         0x08
+#define REG_LCR         0x0c
+#define REG_MCR         0x10
+#define REG_LSR         0x14
+#define REG_MSR         0x18
+#define REG_SCR         0x1c

 #define LSR_DR          0x01  /* Data ready */
 #define LSR_OE          0x02  /* Overrun */

Both input and output works now for lpc_serial (UART=lpc_serial make) build of micropython.

rgc:~/i/microwatt$ ./core_tb > debug_log
MicroPython v1.19.1-782-g699477d12-dirty on 2023-01-10; bare-metal with POWERPC
Type "help()" for more information.
>>> 1+19
20
>>>

@titof49
Copy link

titof49 commented Jan 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants