Skip to content

Commit

Permalink
pw_emu: Add Android build files
Browse files Browse the repository at this point in the history
Add Android build files for pw_emu and it's Pigweed dependencies
(pw_env_setup).

Bug: 316080297
Change-Id: I91122d0f96a877ba90f92ea42b6ab266736486a8
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/186831
Reviewed-by: Jonathon Reinhart <[email protected]>
Reviewed-by: Armando Montanez <[email protected]>
Commit-Queue: Octavian Purdila <[email protected]>
  • Loading branch information
tavip authored and CQ Bot Account committed Jan 26, 2024
1 parent 9ab076f commit 894c1ef
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
25 changes: 21 additions & 4 deletions pw_emu/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,28 @@ Get started
.. tab-item:: CMake

``pw_emu`` is currently only supported for GN-based projects.
``pw_emu`` is not currently supported for CMake-based projects.

.. tab-item:: Zephyr

``pw_emu`` is currently only supported for GN-based projects.
``pw_emu`` is not currently supported for Zephyr-based projects.

.. tab-item:: Android host

Create a :ref:`pigweed.json <seed-0101>` file and include the
desired emulator targets.

Build the ``pw emu`` standalone Android Python executable:

.. code-block:: console
m pw_emu_py
Run ``pw emu``:

.. code-block:: console
pw_emu_py -c <path to pigweed.json> start <emulator target>
------------------------
Set up emulation targets
Expand Down Expand Up @@ -199,7 +216,7 @@ Next, a ``gdb`` session is started and connected to the emulator instance:
Reading symbols from out/stm32f429i_disc1_debug/obj/pw_status/test/status_test.elf...
Remote debugging using ::1:32979
pw::sys_io::WriteByte (b=(unknown: 0x20)) at pw_sys_io_baremetal_lm3s6965evb/sys_io_baremetal.cc:117
117 uart0.data_register = static_cast<uint32_t>(b);
117 uart0.data_register = static_cast<uint32_t>(b);
(gdb) bt
#0 pw::sys_io::WriteByte (b=(unknown: 0x20)) at pw_sys_io_baremetal_lm3s6965evb/sys_io_baremetal.cc:117
#1 0x00002f6a in pw::sys_io::WriteBytes (src=...) at pw_span/public/pw_span/internal/span_impl.h:408
Expand Down Expand Up @@ -246,7 +263,7 @@ a debugging session with ``pw emu gdb``:
Reading symbols from out/lm3s6965evb_qemu_gcc_size_optimized//obj/pw_status/test/status_test...
Remote debugging using ::1:38723
pw_boot_Entry () at pw_boot_cortex_m/core_init.c:122
122 asm volatile("cpsid i");
122 asm volatile("cpsid i");
(gdb)
The program stops at the :ref:`pw_boot_Entry() <module-pw_boot>` function. From
Expand Down
36 changes: 36 additions & 0 deletions pw_emu/py/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2024 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.

package {
default_applicable_licenses: ["external_pigweed_license"],
}

python_binary_host {
name: "pw_emu_py",
main: "pw_emu/__main__.py",
srcs: [
"pw_emu/*.py",
],
libs: [
"pw_env_setup_py_lib",
"pyserial",
],
}

python_library_host {
name: "pw_emu_py_lib",
srcs: [
"pw_emu/*.py",
],
}
24 changes: 24 additions & 0 deletions pw_env_setup/py/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2024 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.

package {
default_applicable_licenses: ["external_pigweed_license"],
}

python_library_host {
name: "pw_env_setup_py_lib",
srcs: [
"pw_env_setup/*.py",
],
}

0 comments on commit 894c1ef

Please sign in to comment.