0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ESP32: 同じプログラムを実機と QEMU で走らせる

Posted at

参考ページ
WSL2でQEMU上の仮想ESP32での開発

esp-idf の準備はこちら
esp-idf の使い方

QEMU を使えるようにする

sudo apt install -y libgcrypt20 libglib2.0-0 libpixman-1-0 libsdl2-2.0-0 libslirp0
python $IDF_PATH/tools/idf_tools.py install qemu-xtensa qemu-riscv32
. $HOME/esp/esp-idf/export.sh

ソースコードの用意

cd ~/esp
cp -r esp-idf/examples/get-started/hello_world .

ソースコードの修正

cd hello_world
main/hello_world.c
// -----------------------------------------------------------------------
/*
	main/hello_world_main.c

					Aug/04/2024
*/
// -----------------------------------------------------------------------
#include <stdio.h>
#include <unistd.h>

#define	VERSION	"2024-8-04 AM 11:54"
// -----------------------------------------------------------------------
void loop()
{
	int icount = 0;

	while(1)
	{
	printf("icount = %d\n",icount);
	printf("*** loop *** %s ***\n",VERSION);
	printf("Hello world!\n");
	printf("Good Morning!\n");
	printf("Good Afternoon!\n");
	printf("こんにちは\n");
	printf("\n");
	printf("*** check *** %s ***\n",VERSION);
	sleep(3);

	icount++;
	}
}

// -----------------------------------------------------------------------
void app_main(void)
{
	sleep(3);
	printf("*** 開始 *** %s ***\n",VERSION);
	sleep(3);

	loop();
}

// -----------------------------------------------------------------------

コンパイル

idf.py build

実機で動かす

df.py flash
$ cu -l /dev/ttyUSB0 -s 115200
Connected.
icount = 0
*** loop *** 2024-8-04 AM 11:54 ***
Hello world!
Good Morning!
Good Afternoon!
こんにちは

*** check *** 2024-8-04 AM 11:54 ***
icount = 1
*** loop *** 2024-8-04 AM 11:54 ***
Hello world!
Good Morning!
Good Afternoon!
こんにちは

*** check *** 2024-8-04 AM 11:54 ***

QEMU で動かす

idf.py qemu monitor

image.png

停止させるには

Process を調べて

ps ax | grep esp
kill -9 **** ****
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?