ue,sa: can sync and receive pbch successfully

master
Ismael Gomez 3 years ago
parent 219bae4fd3
commit 46f4be458a

@ -51,7 +51,7 @@ struct phy_args_t {
uint32_t nof_lte_carriers = 1; uint32_t nof_lte_carriers = 1;
uint32_t nof_nr_carriers = 0; uint32_t nof_nr_carriers = 0;
uint32_t nr_max_nof_prb = 106; uint32_t nr_max_nof_prb = 52;
uint32_t nof_rx_ant = 1; uint32_t nof_rx_ant = 1;
std::string equalizer_mode = "mmse"; std::string equalizer_mode = "mmse";
int cqi_max = 15; int cqi_max = 15;

@ -44,7 +44,7 @@ public:
bool disable_cfo = false; bool disable_cfo = false;
float pbch_dmrs_thr = 0.0f; ///< PBCH DMRS correlation detection threshold (0 means auto) float pbch_dmrs_thr = 0.0f; ///< PBCH DMRS correlation detection threshold (0 means auto)
float cfo_alpha = 0.0f; ///< CFO averaging alpha (0 means auto) float cfo_alpha = 0.0f; ///< CFO averaging alpha (0 means auto)
int thread_priority = -1; int thread_priority = 1;
cell_search::args_t get_cell_search() const cell_search::args_t get_cell_search() const
{ {

@ -124,7 +124,7 @@ static int parse_args(all_args_t* args, int argc, char* argv[])
("rat.nr.bands", bpo::value<string>(&args->stack.rrc_nr.supported_bands_nr_str)->default_value("78"), "Supported NR bands") ("rat.nr.bands", bpo::value<string>(&args->stack.rrc_nr.supported_bands_nr_str)->default_value("78"), "Supported NR bands")
("rat.nr.nof_carriers", bpo::value<uint32_t>(&args->phy.nof_nr_carriers)->default_value(0), "Number of NR carriers") ("rat.nr.nof_carriers", bpo::value<uint32_t>(&args->phy.nof_nr_carriers)->default_value(0), "Number of NR carriers")
("rat.nr.max_nof_prb", bpo::value<uint32_t>(&args->phy.nr_max_nof_prb)->default_value(106), "Maximum NR carrier bandwidth in PRB") ("rat.nr.max_nof_prb", bpo::value<uint32_t>(&args->phy.nr_max_nof_prb)->default_value(52), "Maximum NR carrier bandwidth in PRB")
("rrc.feature_group", bpo::value<uint32_t>(&args->stack.rrc.feature_group)->default_value(0xe6041000), "Hex value of the featureGroupIndicators field in the" ("rrc.feature_group", bpo::value<uint32_t>(&args->stack.rrc.feature_group)->default_value(0xe6041000), "Hex value of the featureGroupIndicators field in the"
"UECapabilityInformation message. Default 0xe6041000") "UECapabilityInformation message. Default 0xe6041000")

@ -79,6 +79,8 @@ int phy_nr_sa::init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_,
logger.set_level(srslog::str_to_basic_level(args.log.phy_level)); logger.set_level(srslog::str_to_basic_level(args.log.phy_level));
logger.set_hex_dump_max_size(args.log.phy_hex_limit); logger.set_hex_dump_max_size(args.log.phy_hex_limit);
logger.set_context(0);
if (!check_args(args)) { if (!check_args(args)) {
return SRSRAN_ERROR; return SRSRAN_ERROR;
} }
@ -93,6 +95,7 @@ int phy_nr_sa::init(const phy_args_nr_t& args_, stack_interface_phy_nr* stack_,
void phy_nr_sa::init_background() void phy_nr_sa::init_background()
{ {
nr::sync_sa::args_t sync_args = {}; nr::sync_sa::args_t sync_args = {};
sync_args.srate_hz = srsran_sampling_freq_hz(args.max_nof_prb);
if (not sync.init(sync_args, stack, radio)) { if (not sync.init(sync_args, stack, radio)) {
logger.error("Error initialising SYNC"); logger.error("Error initialising SYNC");
return; return;
@ -199,6 +202,7 @@ bool phy_nr_sa::start_cell_select(const cell_select_args_t& req)
selected_cell = req.carrier; selected_cell = req.carrier;
cmd_worker_cell.add_cmd([this, req]() { cmd_worker_cell.add_cmd([this, req]() {
// Request cell search to lower synchronization instance. // Request cell search to lower synchronization instance.
sync.cell_select_run(req); sync.cell_select_run(req);
}); });
@ -239,11 +243,6 @@ bool phy_nr_sa::set_config(const srsran::phy_cfg_nr_t& cfg)
// Setup carrier configuration asynchronously // Setup carrier configuration asynchronously
cmd_worker.add_cmd([this]() { cmd_worker.add_cmd([this]() {
// tune radio
logger.info("Tuning Rx channel %d to %.2f MHz", 0, config_nr.carrier.dl_center_frequency_hz / 1e6);
radio->set_rx_freq(0, config_nr.carrier.dl_center_frequency_hz);
logger.info("Tuning Tx channel %d to %.2f MHz", 0, config_nr.carrier.ul_center_frequency_hz / 1e6);
radio->set_tx_freq(0, config_nr.carrier.ul_center_frequency_hz);
// Set UE configuration // Set UE configuration
bool ret = workers.set_config(config_nr); bool ret = workers.set_config(config_nr);

@ -39,6 +39,10 @@ bool sync_sa::init(const args_t& args, stack_interface_phy_nr* stack_, srsran::r
return false; return false;
} }
// Cell bandwidth must be provided at init so set now sampling rate
radio->set_rx_srate(args.srate_hz);
radio->set_tx_srate(args.srate_hz);
// Compute subframe size // Compute subframe size
slot_sz = (uint32_t)(args.srate_hz / 1000.0f); slot_sz = (uint32_t)(args.srate_hz / 1000.0f);
@ -123,9 +127,6 @@ cell_search::ret_t sync_sa::cell_search_run(const cell_search::cfg_t& cfg)
return cs_ret; return cs_ret;
} }
// Set RX frequency
radio->set_rx_freq(0, cfg.center_freq_hz);
// Zero receive buffer // Zero receive buffer
srsran_vec_zero(rx_buffer, slot_sz); srsran_vec_zero(rx_buffer, slot_sz);
@ -150,7 +151,11 @@ bool sync_sa::cell_select_run(const phy_interface_rrc_nr::cell_select_args_t& re
rrc_proc_state = PROC_SELECT_RUNNING; rrc_proc_state = PROC_SELECT_RUNNING;
// Reconfigure cell if necessary // tune radio
logger.info("Tuning Rx channel %d to %.2f MHz", 0, req.carrier.dl_center_frequency_hz / 1e6);
radio->set_rx_freq(0, req.carrier.dl_center_frequency_hz);
logger.info("Tuning Tx channel %d to %.2f MHz", 0, req.carrier.ul_center_frequency_hz / 1e6);
radio->set_tx_freq(0, req.carrier.ul_center_frequency_hz);
// SFN synchronization // SFN synchronization
phy_state.run_sfn_sync(); phy_state.run_sfn_sync();
@ -171,17 +176,32 @@ sync_state::state_t sync_sa::get_state()
void sync_sa::run_state_idle() void sync_sa::run_state_idle()
{ {
if (radio->is_init()) { #define test 0
if (radio->is_init() && test) {
logger.debug("Discarding samples and sending tx_end"); logger.debug("Discarding samples and sending tx_end");
srsran::rf_buffer_t rf_buffer = {};
rf_buffer.set_nof_samples(slot_sz);
rf_buffer.set(0, rx_buffer);
if (not slot_synchronizer.recv_callback(rf_buffer, last_rx_time.get_ptr(0))) {
logger.error("SYNC: receiving from radio\n");
}
radio->tx_end(); radio->tx_end();
} else { } else {
logger.debug("Sleeping 1 ms"); logger.debug("Sleeping 1 s");
usleep(1000); sleep(1);
} }
} }
void sync_sa::run_state_cell_search() void sync_sa::run_state_cell_search()
{ {
// Receive samples
srsran::rf_buffer_t rf_buffer = {};
rf_buffer.set_nof_samples(slot_sz);
rf_buffer.set(0, rx_buffer);
if (not slot_synchronizer.recv_callback(rf_buffer, last_rx_time.get_ptr(0))) {
logger.error("SYNC: receiving from radio\n");
}
// Run Searcher // Run Searcher
cs_ret = searcher.run_slot(rx_buffer, slot_sz); cs_ret = searcher.run_slot(rx_buffer, slot_sz);
if (cs_ret.result < 0) { if (cs_ret.result < 0) {
@ -199,15 +219,12 @@ void sync_sa::run_state_cell_search()
void sync_sa::run_state_cell_select() void sync_sa::run_state_cell_select()
{ {
// TODO // TODO
tti = 0; tti = 10240 - 4;
phy_state.state_exit(); phy_state.state_exit();
} }
void sync_sa::run_state_cell_camping() void sync_sa::run_state_cell_camping()
{ {
// Update logging TTI
logger.set_context(tti);
last_rx_time.add(FDD_HARQ_DELAY_DL_MS * 1e-3); last_rx_time.add(FDD_HARQ_DELAY_DL_MS * 1e-3);
nr::sf_worker* nr_worker = nullptr; nr::sf_worker* nr_worker = nullptr;
@ -217,6 +234,16 @@ void sync_sa::run_state_cell_camping()
return; return;
} }
// Receive samples
srsran::rf_buffer_t rf_buffer = {};
rf_buffer.set_nof_samples(slot_sz);
rf_buffer.set(0, nr_worker->get_buffer(0, 0));
if (not slot_synchronizer.recv_callback(rf_buffer, last_rx_time.get_ptr(0))) {
logger.error("SYNC: receiving from radio\n");
}
printf("sync_tti=%d, power=%f\n", tti, srsran_vec_avg_power_cf(rf_buffer.get(0), 11520));
srsran::phy_common_interface::worker_context_t context; srsran::phy_common_interface::worker_context_t context;
context.sf_idx = tti; context.sf_idx = tti;
context.worker_ptr = nr_worker; context.worker_ptr = nr_worker;
@ -235,22 +262,10 @@ void sync_sa::run_state_cell_camping()
void sync_sa::run_thread() void sync_sa::run_thread()
{ {
while (running.load(std::memory_order_relaxed)) { while (running.load(std::memory_order_relaxed)) {
logger.debug("SYNC: state=%s, tti=%d", phy_state.to_string(), tti); logger.set_context(tti);
// Setup RF buffer for 1ms worth of samples logger.debug("SYNC: state=%s, tti=%d", phy_state.to_string(), tti);
if (radio->is_init()) {
srsran::rf_buffer_t rf_buffer = {};
rf_buffer.set_nof_samples(slot_sz);
rf_buffer.set(0, rx_buffer);
#ifdef useradio
if (not slot_synchronizer.recv_callback(rf_buffer, last_rx_time.get_ptr(0))) {
logger.error("SYNC: receiving from radio\n");
}
#else
sleep(1);
#endif
}
switch (phy_state.run_state()) { switch (phy_state.run_state()) {
case sync_state::IDLE: case sync_state::IDLE:
run_state_idle(); run_state_idle();
@ -287,8 +302,9 @@ void sync_sa::worker_end(const srsran::phy_common_interface::worker_context_t& w
// Check if any worker had a transmission // Check if any worker had a transmission
if (tx_enable) { if (tx_enable) {
// Actual baseband transmission // Actual baseband transmission
#ifdef useradio
radio->tx(tx_buffer, tx_time); radio->tx(tx_buffer, tx_time);
#endif
} else { } else {
if (radio->is_continuous_tx()) { if (radio->is_continuous_tx()) {
if (is_pending_tx_end) { if (is_pending_tx_end) {

@ -229,11 +229,21 @@ int rrc_nr::connection_request(srsran::nr_establishment_cause_t cause, srsran::u
cfg.duplex = srsran::phy_cfg_nr_default_t::reference_cfg_t::R_DUPLEX_FDD; cfg.duplex = srsran::phy_cfg_nr_default_t::reference_cfg_t::R_DUPLEX_FDD;
phy_cfg = srsran::phy_cfg_nr_default_t{srsran::phy_cfg_nr_default_t::reference_cfg_t{cfg}}; phy_cfg = srsran::phy_cfg_nr_default_t{srsran::phy_cfg_nr_default_t::reference_cfg_t{cfg}};
phy_cfg.ssb.periodicity_ms = 10;
phy_cfg.carrier.ssb_center_freq_hz = 1842.05e6;
phy_cfg.carrier.dl_center_frequency_hz = 1842.5e6;
phy_cfg.carrier.ul_center_frequency_hz = 1747.5e6;
phy_interface_rrc_nr::cell_select_args_t cell_cfg = {}; phy_interface_rrc_nr::cell_select_args_t cell_cfg = {};
cell_cfg.carrier = phy_cfg.carrier; cell_cfg.carrier = phy_cfg.carrier;
cell_cfg.ssb_cfg = phy_cfg.get_ssb_cfg(); cell_cfg.ssb_cfg = phy_cfg.get_ssb_cfg();
phy->start_cell_select(cell_cfg); phy->start_cell_select(cell_cfg);
sleep(1); sleep(1);
srsran::rach_nr_cfg_t rach_cfg = {};
mac->set_config(rach_cfg);
phy_cfg_state = PHY_CFG_STATE_APPLY_SP_CELL;
phy->set_config(phy_cfg); phy->set_config(phy_cfg);
return SRSRAN_SUCCESS; return SRSRAN_SUCCESS;
} }

Loading…
Cancel
Save